-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Check "x/net/context" with go vet
like "context"
#1490
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/bash | ||
|
||
set -ex # Exit on error; debugging enabled. | ||
set -o pipefail # Fail a pipe if any sub-command fails. | ||
|
||
die() { | ||
echo "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
# TODO: Remove this check and the mangling below once "context" is imported | ||
# directly. | ||
if git status --porcelain | read; then | ||
die "Uncommitted or untracked files found; commit changes first" | ||
fi | ||
# Undo any edits made by this script. | ||
cleanup() { | ||
git reset --hard HEAD | ||
} | ||
trap cleanup EXIT | ||
|
||
# Check proto in manual runs or cron runs. | ||
if [[ "$TRAVIS" != "true" || "$TRAVIS_EVENT_TYPE" = "cron" ]]; then | ||
check_proto="true" | ||
fi | ||
|
||
if [ "$1" = "-install" ]; then | ||
go get -d \ | ||
google.golang.org/grpc/... | ||
go get -u \ | ||
github.com/golang/lint/golint \ | ||
golang.org/x/tools/cmd/goimports \ | ||
honnef.co/go/tools/cmd/staticcheck \ | ||
github.com/golang/protobuf/protoc-gen-go \ | ||
golang.org/x/tools/cmd/stringer | ||
if [[ "$check_proto" = "true" ]]; then | ||
if [[ "$TRAVIS" = "true" ]]; then | ||
PROTOBUF_VERSION=3.3.0 | ||
cd /home/travis | ||
wget https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/$basename-linux-x86_64.zip | ||
unzip $basename-linux-x86_64.zip | ||
bin/protoc --version | ||
elif ! which protoc > /dev/null; then | ||
die "Please install protoc into your path" | ||
fi | ||
fi | ||
exit 0 | ||
elif [[ "$#" -ne 0 ]]; then | ||
die "Unknown argument(s): $*" | ||
fi | ||
|
||
git ls-files "*.go" | xargs grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)\|DO NOT EDIT" 2>&1 | tee /dev/stderr | (! read) | ||
gofmt -s -d -l . 2>&1 | tee /dev/stderr | (! read) | ||
goimports -l . 2>&1 | tee /dev/stderr | (! read) | ||
golint ./... 2>&1 | (grep -vE "(_mock|_string|\.pb)\.go:" || true) | tee /dev/stderr | (! read) | ||
|
||
# Rewrite golang.org/x/net/context -> context imports (see grpc/grpc-go#1484). | ||
# TODO: Remove this mangling once "context" is imported directly (grpc/grpc-go#711). | ||
git ls-files "*.go" | xargs sed -i 's:"golang.org/x/net/context":"context":' | ||
set +o pipefail | ||
# TODO: Stop filtering pb.go files once golang/protobuf#214 is fixed. | ||
# TODO: Remove clientconn exception once go1.6 support is removed. | ||
go tool vet -all . 2>&1 | grep -vE 'clientconn.go:.*cancel' | grep -vF '.pb.go:' | tee /dev/stderr | (! read) | ||
set -o pipefail | ||
git reset --hard HEAD | ||
|
||
if [[ "$check_proto" = "true" ]]; then | ||
PATH=/home/travis/bin:$PATH make proto && \ | ||
git status --porcelain 2>&1 | (! read) || \ | ||
(git status; git --no-pager diff; exit 1) | ||
fi | ||
|
||
# TODO(menghanl): fix errors in transport_test. | ||
staticcheck -ignore google.golang.org/grpc/transport/transport_test.go:SA2002 ./... |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep this?
Though this works on travis, someone trying to run
make proto
locally may fail because of these two missing packages...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with reverting this, but then we should change
make proto
invet.sh
to rungo generate
. Otherwise you end up with the latency ofgo get
every time you runvet.sh
, which is not really desirable.Alternatively, we can check
$GOPATH/.....
for these two things and fail with a friendlier error if they are not found.Thoughts?