5
5
6
6
source devtools/lib.sh || { echo " Are you at repo root?" ; exit 1; }
7
7
8
+ GO=go
8
9
9
10
# Support ** in globs, for check_script_hashes.
10
11
shopt -s globstar
@@ -90,14 +91,14 @@ findcode() {
90
91
}
91
92
92
93
# ensure_go_binary verifies that a binary exists in $PATH corresponding to the
93
- # given go-gettable URI. If no such binary exists, it is fetched via `go get `.
94
+ # given go-gettable URI. If no such binary exists, it is fetched via `go install `.
94
95
ensure_go_binary () {
95
96
local binary=$( basename $1 )
96
97
if ! [ -x " $( command -v $binary ) " ]; then
97
98
info " Installing: $1 "
98
99
# Run in a subshell for convenience, so that we don't have to worry about
99
100
# our PWD.
100
- (set -x; cd && go install $1 @latest)
101
+ (set -x; cd && $GO install $1 @latest)
101
102
fi
102
103
}
103
104
@@ -140,7 +141,7 @@ check_unparam() {
140
141
141
142
# check_vet runs go vet on source files.
142
143
check_vet () {
143
- runcmd go vet -all ./...
144
+ runcmd $GO vet -all ./...
144
145
}
145
146
146
147
# check_staticcheck runs staticcheck on source files.
@@ -174,12 +175,12 @@ script_hash_glob='static/**/*.tmpl'
174
175
# check_script_hashes checks that our CSP hashes match the ones
175
176
# for our HTML scripts.
176
177
check_script_hashes () {
177
- runcmd go run ./devtools/cmd/csphash $script_hash_glob
178
+ runcmd $GO run ./devtools/cmd/csphash $script_hash_glob
178
179
}
179
180
180
181
# run_build_static builds JavaScript output from TypeScript source files.
181
182
run_build_static () {
182
- runcmd go run ./devtools/cmd/static
183
+ runcmd $GO run ./devtools/cmd/static
183
184
}
184
185
185
186
run_npm () {
@@ -272,9 +273,9 @@ main() {
272
273
run_prettier
273
274
run_npm run lint -- --fix
274
275
run_npm run test
275
- runcmd go mod tidy
276
+ runcmd $GO mod tidy
276
277
runcmd env GO_DISCOVERY_TESTDB=true go test ./...
277
- runcmd go test ./internal/secrets
278
+ runcmd $GO test ./internal/secrets
278
279
run_npm audit
279
280
;;
280
281
cl)
@@ -306,9 +307,9 @@ main() {
306
307
run_npm run lint -- --fix
307
308
run_npm run test
308
309
fi
309
- runcmd go mod tidy
310
+ runcmd $GO mod tidy
310
311
runcmd env GO_DISCOVERY_TESTDB=true go test ./...
311
- runcmd go test ./internal/secrets
312
+ runcmd $GO test ./internal/secrets
312
313
;;
313
314
314
315
ci)
@@ -325,13 +326,13 @@ main() {
325
326
echo " DONE: $(( end- start)) seconds"
326
327
echo " --------------------"
327
328
328
- for pkg in $( go list ./...) ; do
329
+ for pkg in $( $GO list ./...) ; do
329
330
if [[ ${no_race[$pkg]} = ' ' ]]; then
330
331
race=" $race $pkg "
331
332
fi
332
333
done
333
- runcmd env GO_DISCOVERY_TESTDB=true go test -race -count=1 $race
334
- runcmd env GO_DISCOVERY_TESTDB=true go test -count=1 ${! no_race[*]}
334
+ runcmd env GO_DISCOVERY_TESTDB=true $GO test -race -count=1 $race
335
+ runcmd env GO_DISCOVERY_TESTDB=true $GO test -count=1 ${! no_race[*]}
335
336
;;
336
337
lint) standard_linters ;;
337
338
headers) check_headers ;;
0 commit comments