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: set the Go Version for command-line files to be the containing module's Go Version #68159

samthanawalla opened this issue Jun 24, 2024 · 3 comments


Copy link

samthanawalla commented Jun 24, 2024

Current behavior

The Go version for a file passed in via command-line uses the local version.
e.g. $ go vet -x main.go
will set the Go Version to be the local version.

This happens in 3 places (maybe more):

  1. vet
  2. compiler
  3. init.go

This ignores whether or not the file has a containing module.
e.g. current go version running is 1.23
-> main.go
-> go.mod (1.21)

$ go vet -x main.go
will set the Go Version to be 1.23

New behavior

As discussed offline and in we have come to the decision to set the Go version to use the containing go.mod's version.
In the above example, $ go vet -x main.go
will set the Go Version to be 1.21

@samthanawalla samthanawalla added this to the Go1.24 milestone Jun 24, 2024
@samthanawalla samthanawalla self-assigned this Jun 24, 2024
Copy link
Contributor Author

Thanks Gaby. Duplicate of #36875

@samthanawalla samthanawalla closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2024
@rsc rsc reopened this Jul 3, 2024
Copy link

rsc commented Jul 3, 2024

I closed the proposal since it was so stale and mostly done. Reopening this issue.

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

No branches or pull requests

3 participants