-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Open
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolProposalIssues describing a requested change to a Go tool or command-line program.Issues describing a requested change to a Go tool or command-line program.
Milestone
Description
env GOTOOLCHAIN=go1.26.0
exec go version
exec go run .
exec go test
exec go vet
-- go.mod --
module test
go 1.25.0
-- main.go --
package main
import "bytes"
func main() { var _ = (*bytes.Buffer).Peek }
-- main_test.go --
package main_test
import "testing"
func TestDummy(t *testing.T) {}
> env GOTOOLCHAIN=go1.26.0
> exec go version
[stdout]
go version go1.26.0 linux/amd64
[stderr]
go: downloading go1.26.0 (linux/amd64)
> exec go run .
> exec go test
[stdout]
PASS
ok test 0.001s
> exec go vet
[stderr]
main.go:5:39: bytes.Peek requires go1.26 or later (file is go1.25)
[exit status 1]
It's a shame that go test doesn't surface this problem; even though go vet and gopls do surface it loudly, the sooner the user can correct this problem, the better. Otherwise they could later on find themselves in a situation where they have to rewrite code to stop using new APIs or language features.
I also wonder why this check wasn't added to go test once it was introduced; it seems like a simple (and presumably fast) check that should have zero false negatives. I imagine there are other similar checks that would be a good addition as well.
Split from #77653 (comment).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolProposalIssues describing a requested change to a Go tool or command-line program.Issues describing a requested change to a Go tool or command-line program.