mirror of
https://github.com/golang/go
synced 2024-11-23 18:30:06 -07:00
cmd/go: support workspaces in vet
Add modload.InitWorkfile to runVet so that the vet command recognizes and uses the workspace. Fixes #51072 Change-Id: Ia6727eff9b80eb33627f5ae23e4d72cde581e75f Reviewed-on: https://go-review.googlesource.com/c/go/+/385176 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
0a9d6a31b1
commit
23386b5f67
@ -13,6 +13,7 @@ import (
|
||||
"cmd/go/internal/base"
|
||||
"cmd/go/internal/cfg"
|
||||
"cmd/go/internal/load"
|
||||
"cmd/go/internal/modload"
|
||||
"cmd/go/internal/trace"
|
||||
"cmd/go/internal/work"
|
||||
)
|
||||
@ -54,6 +55,7 @@ See also: go fmt, go fix.
|
||||
|
||||
func runVet(ctx context.Context, cmd *base.Command, args []string) {
|
||||
vetFlags, pkgArgs := vetFlags(args)
|
||||
modload.InitWorkfile() // The vet command does custom flag processing; initialize workspaces after that.
|
||||
|
||||
if cfg.DebugTrace != "" {
|
||||
var close func() error
|
||||
|
19
src/cmd/go/testdata/script/work_vet.txt
vendored
Normal file
19
src/cmd/go/testdata/script/work_vet.txt
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
! go vet ./a
|
||||
stderr 'fmt.Println call has possible formatting directive'
|
||||
|
||||
-- go.work --
|
||||
go 1.18
|
||||
|
||||
use ./a
|
||||
-- a/go.mod --
|
||||
module example.com/a
|
||||
|
||||
go 1.18
|
||||
-- a/a.go --
|
||||
package a
|
||||
|
||||
import "fmt"
|
||||
|
||||
func A() {
|
||||
fmt.Println("%s")
|
||||
}
|
Loading…
Reference in New Issue
Block a user