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

Open
samthanawalla opened this issue Jun 24, 2024 · 3 comments
Assignees
Labels
Milestone

Comments

@samthanawalla
Copy link
Contributor

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 https://go-review.googlesource.com/c/go/+/567435 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
@samthanawalla
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
@rsc
Copy link
Contributor

rsc commented Jul 3, 2024

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

@seankhliao seankhliao added the GoCommand cmd/go label Jul 13, 2024
@samthanawalla samthanawalla modified the milestones: Go1.24, Go1.25 Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants