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: document that generate processes packages in command line order #19762

Open
myitcv opened this Issue Mar 29, 2017 · 3 comments

Comments

Projects
None yet
6 participants
@myitcv
Member

myitcv commented Mar 29, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/mgo/src/modelogiq.com/g/_vendor:/home/myitcv/mgo"
GORACE=""
GOROOT="/home/myitcv/gos"
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build675075507=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

go generate accepts a number of packages as arguments, packages on which to run go generate. go generate -help makes no mention of the order in which those packages will be go generate-d

The lack of any mention on the order of execution might well be intentional...

But in any case I'd like to propose we define the order and document it (this issue could conceivably be a proposal, very happy to redo as such)

The use case stems a use case where go generate-ors end up parsing dependencies in order to make decisions on their output. In this context, having go generate run in reverse dependency order (there's probably a more precise term?) on the set of packages provided as arguments avoids the need to re-run go generate multiple times (which incidentally is the current alternative, clearly not ideal)

What did you expect to see?

"Expect" is not the correct word here... because the order is unspecified I can't reasonably have an expectation. More a "hope" perhaps that:

go generate should run in reverse-dependency order on the set of packages passed to it as arguments.

What did you see instead?

It runs in an unspecified order.

cc @robpike perhaps?

@ALTree ALTree added this to the Go1.10 milestone Jul 18, 2017

@rsc rsc modified the milestones: Go1.10, Go1.11 Dec 1, 2017

@rsc

This comment has been minimized.

Contributor

rsc commented Apr 18, 2018

It runs in the same order as go list: sorted by identifying import path.
Documenting this is fine.
Changing it is not.

@rsc rsc changed the title from cmd/go: generate does not specify order of execution for package arguments to cmd/go: document that generate processes packages sorted by import path Apr 18, 2018

@rsc rsc added NeedsFix and removed NeedsDecision labels Apr 18, 2018

@rsc

This comment has been minimized.

Contributor

rsc commented Apr 18, 2018

Actually the order of "go list" is "as listed on the command line".
Wildcards expand in sorted order within the command line
but that doesn't matter much here.

@rsc rsc changed the title from cmd/go: document that generate processes packages sorted by import path to cmd/go: document that generate processes packages in command line order Apr 18, 2018

@myitcv

This comment has been minimized.

Member

myitcv commented Apr 18, 2018

Documenting this is fine. Changing it is not.

Makes total sense.

@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Go1.12 Jul 6, 2018

@agnivade agnivade added the Suggested label Dec 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment