Skip to content

cmd/go: always pass a GoVersion to cmd/vet #65612

Closed
@timothy-king

Description

@timothy-king

Reported by @alexaandru in #63888 (comment)

$ cat go.mod
module example.com/m

go 1.22.0
$ cat main.go
package main

func main() {
	for i := range 10 {
		go func() { println(i) }()
	}
}

No output (as expected) when running as a package:

$ go1.22.0 vet example.com/m

False positive when running on a file:

$ go1.22.0 vet main.go
# command-line-arguments
# [command-line-arguments]
./main.go:5:23: loop variable i captured by func literal

go1.22.0 vet -x -json example.com/m gives the GoVersion as "GoVersion": "go1.22.0",. go1.22.0 vet -x -json main.go gives the GoVersion as "GoVersion": "",.

@bcmills

Metadata

Metadata

Assignees

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Thinkingmodules

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions