mirror of
https://github.com/golang/go.git
synced 2026-02-03 01:15:04 +03:00
cmd/go/internal/vet: only set work.VetExplicit if the list of explicit flags is non-empty
Updates #35837 Fixes #37030 Change-Id: Ifd3435803622a8624bab55a0f3fbc8855025282f Reviewed-on: https://go-review.googlesource.com/c/go/+/217897 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
@@ -51,7 +51,9 @@ func runVet(cmd *base.Command, args []string) {
|
||||
|
||||
work.BuildInit()
|
||||
work.VetFlags = vetFlags
|
||||
work.VetExplicit = true
|
||||
if len(vetFlags) > 0 {
|
||||
work.VetExplicit = true
|
||||
}
|
||||
if vetTool != "" {
|
||||
var err error
|
||||
work.VetTool, err = filepath.Abs(vetTool)
|
||||
|
||||
11
src/cmd/go/testdata/script/vet_flags.txt
vendored
11
src/cmd/go/testdata/script/vet_flags.txt
vendored
@@ -6,6 +6,17 @@ go vet -n -unreachable=false encoding/binary
|
||||
stderr '-unreachable=false'
|
||||
! stderr '-unsafeptr=false'
|
||||
|
||||
# Issue 37030: "go vet <std package>" without other flags should disable the
|
||||
# unsafeptr check by default.
|
||||
go vet -n encoding/binary
|
||||
stderr '-unsafeptr=false'
|
||||
! stderr '-unreachable=false'
|
||||
|
||||
# However, it should be enabled if requested explicitly.
|
||||
go vet -n -unsafeptr encoding/binary
|
||||
stderr '-unsafeptr'
|
||||
! stderr '-unsafeptr=false'
|
||||
|
||||
[short] stop
|
||||
env GOCACHE=$WORK/gocache
|
||||
env GOTMPDIR=$WORK/tmp
|
||||
|
||||
Reference in New Issue
Block a user