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.
I sometimes use
go run -exec
to quickly check how long a program takes to run excluding the build time, for example:Similarly, I have found
go test -exec
very useful on occasion, for example to test for a different OS likeGOOS=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 dogo generate -exec=time ./...
or something similar with a short script.