Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: attempt to make method for shadow checks consistent with 1.12 and 1.13 #1797

Merged
merged 2 commits into from Oct 1, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 18 additions & 10 deletions govet.sh
Expand Up @@ -8,16 +8,24 @@ printf "Running go vet shadow...\n"
command -v shadow >/dev/null 2>&1 || (
dir=$(mktemp -d)
pushd $dir
go mod init tool
go get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
go mod init shadow
# The go vet -vettool option was added in 1.12, and broken in the initial
# 1.13 release for any vettool that doesn't support the unsafeptr flag. The
# shadow tool doesn't support the unsafeptr flag. Until either support for
# unsafeptr is added to shadow or passing through that flag is removed from
# go vet we can use the anazlyer by wrapping it in our own main that ignores
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved
# unsafeptr. This temporary work around was suggested here:
# https://github.com/golang/go/issues/34053
gofmt > main.go <<-EOF
package main
import "flag"
import "golang.org/x/tools/go/analysis/passes/shadow"
import "golang.org/x/tools/go/analysis/singlechecker"
func init() { flag.String("unsafeptr", "", "") }
func main() { singlechecker.Main(shadow.Analyzer) }
EOF
go install
popd
)

# The go vet -vettool option was added in 1.12, and broken in the initial 1.13
# release. Until it is fixed we must call vettool's directly as a work around.
# https://github.com/golang/go/issues/34053
if [[ $GOLANG_VERSION = 1.12.* ]]; then
go vet -vettool=$(which shadow) ./...
else
shadow ./...
fi
go vet -vettool=$(which shadow) ./...