Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: add go generate -exec flag like go run -exec and go test -exec #69487

Open
mvdan opened this issue Sep 16, 2024 · 2 comments
Open

cmd/go: add go generate -exec flag like go run -exec and go test -exec #69487

mvdan opened this issue Sep 16, 2024 · 2 comments
Labels
FeatureRequest GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@mvdan
Copy link
Member

mvdan commented Sep 16, 2024

I sometimes use go run -exec to quickly check how long a program takes to run excluding the build time, for example:

$ /bin/time go run testdata/gen.go 
7.53user 1.17system 0:01.51elapsed 573%CPU (0avgtext+0avgdata 601640maxresident)k
0inputs+384outputs (10major+131651minor)pagefaults 0swaps
$ go run -exec=/bin/time testdata/gen.go 
6.96user 1.08system 0:01.21elapsed 661%CPU (0avgtext+0avgdata 492024maxresident)k
0inputs+224outputs (1major+134476minor)pagefaults 0swaps

Similarly, I have found go test -exec very useful on occasion, for example to test for a different OS like GOOS=windows go test -exec=wine, or to test under a different environment like with https://github.com/mvdan/dockexec.

I wish I could do something similar with go generate. For example, in one of my projects, go generate ./... in CI takes twelve seconds, and I'd like to dig into which of the steps is taking longer than I would expect. For this reason I'd love to be able to do go generate -exec=time ./... or something similar with a short script.

@mvdan mvdan added FeatureRequest GoCommand cmd/go Tools This label describes issues relating to any tools in the x/tools repository. labels Sep 16, 2024
@gabyhelp
Copy link

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 16, 2024
@matloob
Copy link
Contributor

matloob commented Sep 17, 2024

I don't see any immediate problems with this idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants