Skip to content

x/tools/go/packages: should it respect GOROOT? #41231

Closed
@hugelgupf

Description

@hugelgupf

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions