Skip to content

Commit

Permalink
cmd/go/internal/vet: only set work.VetExplicit if the list of explici…
Browse files Browse the repository at this point in the history
…t 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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Jay Conrod <[email protected]>
  • Loading branch information
Bryan C. Mills committed Feb 5, 2020
1 parent 702226f commit 8a4d05c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cmd/go/internal/vet/vet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions src/cmd/go/testdata/script/vet_flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8a4d05c

Please sign in to comment.