Description
What version of Go are you using (go version
)?
many
Does this issue reproduce with the latest release?
yes
What did you do?
Different Go versions have slightly different behaviors in go list
or go mod
. That's ok.
I work on some stuff that uses x/tools/go/packages to do AST transformations on code before compiling it. x/tools/go/packages is near perfect for us, save for one issue: it does not respect GOROOT.
This often comes up for me because I use go get golang.org/dl/go1.x to test whether compilation works under different versions of Go. Those get installed as go1.13
binaries, for example, and invoking
go1.13 run transformer.go -- ...
does not have the desired effect, because for everything underneath, it still uses go
from $PATH, which in my case is 1.15. See exec.Command invocation here.
I've had to replicate some of the stuff from x/tools/go/packages in a development branch in order to use $GOROOT/bin/go instead, and I'm wondering if it'd make sense for x/tools/go/packages to also use $GOROOT/bin/go rather than go from $PATH.
(Apologies for not having a specific example in mind right now -- it's been a long time since I actually worked in this code base, and I'm just now picking it up again. I may be able to give you a better example later.)
cc @heschik @stamblerre