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:
Bryan C. Mills
2020-02-05 13:36:53 -05:00
parent 702226f933
commit 8a4d05cf07
2 changed files with 14 additions and 1 deletions

View File

@@ -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)

View File

@@ -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