]>
git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/google.golang.org/grpc/vet.sh
3 if [[ `uname -a` = *"Darwin"* ]]; then
4 echo "It seems you are running on Mac. This script does not work on Mac. See https://github.com/grpc/grpc-go/issues/2047"
8 set -ex # Exit on error; debugging enabled.
9 set -o pipefail
# Fail a pipe if any sub-command fails.
16 # Check to make sure it's safe to modify the user's git repo.
17 if git status
--porcelain | read; then
18 die
"Uncommitted or untracked files found; commit changes first"
21 if [[ -d "${GOPATH}/src" ]]; then
22 die
"\${GOPATH}/src (${GOPATH}/src) exists; this script will delete it."
25 # Undo any edits made by this script.
27 rm -rf "${GOPATH}/src"
33 tee /dev
/stderr
| (! read)
36 PATH
="${GOPATH}/bin:${GOROOT}/bin:${PATH}"
38 if [[ "$1" = "-install" ]]; then
39 # Check for module support
40 if go
help mod
>& /dev
/null
; then
42 golang.org
/x
/lint
/golint \
43 golang.org
/x
/tools
/cmd
/goimports \
44 honnef.co
/go
/tools
/cmd
/staticcheck \
45 github.com
/client
9/misspell
/cmd
/misspell \
46 github.com
/golang
/protobuf
/protoc
-gen-go
48 # Ye olde `go get` incantation.
49 # Note: this gets the latest version of all tools (vs. the pinned versions
52 golang.org
/x
/lint
/golint \
53 golang.org
/x
/tools
/cmd
/goimports \
54 honnef.co
/go
/tools
/cmd
/staticcheck \
55 github.com
/client
9/misspell
/cmd
/misspell \
56 github.com
/golang
/protobuf
/protoc
-gen-go
58 if [[ -z "${VET_SKIP_PROTO}" ]]; then
59 if [[ "${TRAVIS}" = "true" ]]; then
60 PROTOBUF_VERSION
=3.3.0
61 PROTOC_FILENAME
=protoc
-${PROTOBUF_VERSION}-linux-x86_64.
zip
63 wget https
://github.com
/google
/protobuf
/releases
/download
/v
${PROTOBUF_VERSION}/${PROTOC_FILENAME}
64 unzip ${PROTOC_FILENAME}
67 elif ! which protoc
> /dev
/null
; then
68 die
"Please install protoc into your path"
72 elif [[ "$#" -ne 0 ]]; then
73 die
"Unknown argument(s): $*"
76 # - Ensure all source files contain a copyright message.
77 git
ls-files "*.go" | xargs grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)\|DO NOT EDIT" 2>&1 | fail_on_output
79 # - Make sure all tests in grpc and grpc/test use leakcheck via Teardown.
80 (! grep 'func Test[^(]' *_test.go
)
81 (! grep 'func Test[^(]' test
/*.go
)
83 # - Do not import math/rand for real library code. Use internal/grpcrand for
85 git
ls-files "*.go" | xargs grep -l '"math/rand"' 2>&1 | (! grep -v '^examples\|^stress\|grpcrand')
87 # - Ensure all ptypes proto packages are renamed when importing.
88 git
ls-files "*.go" | (! xargs grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/")
90 # - Check imports that are illegal in appengine (until Go 1.11).
91 # TODO: Remove when we drop Go 1.10 support
92 go list
-f {{.Dir
}} .
/...
| xargs go run test
/go_vet
/vet.go
94 # - gofmt, goimports, golint (with exceptions for generated code), go vet.
95 gofmt
-s -d -l .
2>&1 | fail_on_output
96 goimports
-l .
2>&1 | fail_on_output
97 golint .
/...
2>&1 | (! grep -vE "(_mock|\.pb)\.go:")
100 # - Check that generated proto files are up to date.
101 if [[ -z "${VET_SKIP_PROTO}" ]]; then
102 PATH
="/home/travis/bin:${PATH}" make proto
&& \
103 git status
--porcelain 2>&1 | fail_on_output
|| \
104 (git status
; git
--no-pager diff; exit 1)
107 # - Check that our module is tidy.
108 if go
help mod
>& /dev
/null
; then
110 git status
--porcelain 2>&1 | fail_on_output
|| \
111 (git status
; git
--no-pager diff; exit 1)
114 # - Collection of static analysis checks
115 ### HACK HACK HACK: Remove once staticcheck works with modules.
116 # Make a symlink in ${GOPATH}/src to its ${GOPATH}/pkg/mod equivalent for every package we use.
117 for x
in $(find "${GOPATH}/pkg/mod" -name '*@*' | grep -v \/mod\/cache\/); do
118 pkg
="$(echo ${x#"${GOPATH}/pkg/mod/"} | cut -f1 -d@)";
119 # If multiple versions exist, just use the existing one.
120 if [[ -L "${GOPATH}/src/${pkg}" ]]; then continue; fi
121 mkdir -p "$(dirname "${GOPATH}/src/${pkg}")";
122 ln -s $x "${GOPATH}/src/${pkg}";
124 ### END HACK HACK HACK
126 # TODO(menghanl): fix errors in transport_test.
127 staticcheck
-go 1.9 -ignore '
129 balancer_test.go:SA1019
130 clientconn_test.go:SA1019
131 balancer/roundrobin/roundrobin_test.go:SA1019
132 benchmark/benchmain/main.go:SA1019
133 internal/transport/handler_server.go:SA1019
134 internal/transport/handler_server_test.go:SA1019
135 internal/transport/transport_test.go:SA2002
136 stats/stats_test.go:SA1019
137 test/channelz_test.go:SA1019
138 test/end2end_test.go:SA1019
139 test/healthcheck_test.go:SA1019