go icon indicating copy to clipboard operation
go copied to clipboard

cmd/go: add 'go generate -skip'

Open xtonyjiang opened this issue 4 years ago • 6 comments

We currently have the -run flag, but I believe it is currently impossible to supply a regular expression that would allow for excluding a certain expression (due to no lookaheads in Go's regex syntax). Being able to exclude expressions would be useful if we want to exclude certain directives that are time-consuming and are not needed in the moment, and we want to run a large amount of other directives, so that it would be impractical to simply run go generate multiple times with different -run flags.

I think one way to implement this could be an additional flag. Similar to grep's --invert-match flag, we could do something like:

go generate -invertmatch -run="my excluded pattern" ./...

Alternatively, we could also have a different flag that is used instead of -run, like:

go generate -runexcept="my excluded pattern" ./...

Here, supplying both -runexcept and -run would be invalid.

xtonyjiang avatar Apr 27 '20 10:04 xtonyjiang

I'm not sure we should do anything here, but if we did, it should apply to the other -run flags too.

rsc avatar Jul 14 '21 16:07 rsc

#41583 is an accepted proposal for a go test -skip flag that sounds similar. What about bringing that to go generate?

jayconrod avatar Jul 22 '21 15:07 jayconrod

This proposal has been added to the active column of the proposals project and will now be reviewed at the weekly proposal review meetings. — rsc for the proposal review group

rsc avatar Aug 04 '21 18:08 rsc

Based on the discussion above, this proposal seems like a likely accept. — rsc for the proposal review group

rsc avatar Aug 11 '21 18:08 rsc

No change in consensus, so accepted. 🎉 This issue now tracks the work of implementing the proposal. — rsc for the proposal review group

rsc avatar Aug 18 '21 18:08 rsc

Change https://go.dev/cl/421440 mentions this issue: cmd/go: add go generate -skip flag

gopherbot avatar Aug 05 '22 20:08 gopherbot