pkgsite: prepare for go 1.18

For golang/go#48264

Change-Id: I55e512051450fb4bbc58fe00872c5d7077988ccb
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/382974
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
diff --git a/all.bash b/all.bash
index 765eabc..1702001 100755
--- a/all.bash
+++ b/all.bash
@@ -5,6 +5,7 @@
 
 source devtools/lib.sh || { echo "Are you at repo root?"; exit 1; }
 
+GO=go
 
 # Support ** in globs, for check_script_hashes.
 shopt -s globstar
@@ -90,14 +91,14 @@
 }
 
 # ensure_go_binary verifies that a binary exists in $PATH corresponding to the
-# given go-gettable URI. If no such binary exists, it is fetched via `go get`.
+# given go-gettable URI. If no such binary exists, it is fetched via `go install`.
 ensure_go_binary() {
   local binary=$(basename $1)
   if ! [ -x "$(command -v $binary)" ]; then
     info "Installing: $1"
     # Run in a subshell for convenience, so that we don't have to worry about
     # our PWD.
-    (set -x; cd && go install $1@latest)
+    (set -x; cd && $GO install $1@latest)
   fi
 }
 
@@ -140,7 +141,7 @@
 
 # check_vet runs go vet on source files.
 check_vet() {
-  runcmd go vet -all ./...
+  runcmd $GO vet -all ./...
 }
 
 # check_staticcheck runs staticcheck on source files.
@@ -174,12 +175,12 @@
 # check_script_hashes checks that our CSP hashes match the ones
 # for our HTML scripts.
 check_script_hashes() {
-  runcmd go run ./devtools/cmd/csphash $script_hash_glob
+  runcmd $GO run ./devtools/cmd/csphash $script_hash_glob
 }
 
 # run_build_static builds JavaScript output from TypeScript source files.
 run_build_static() {
-  runcmd go run ./devtools/cmd/static
+  runcmd $GO run ./devtools/cmd/static
 }
 
 run_npm() {
@@ -272,9 +273,9 @@
       run_prettier
       run_npm run lint -- --fix
       run_npm run test
-      runcmd go mod tidy
+      runcmd $GO mod tidy
       runcmd env GO_DISCOVERY_TESTDB=true go test ./...
-      runcmd go test ./internal/secrets
+      runcmd $GO test ./internal/secrets
       run_npm audit
       ;;
     cl)
@@ -306,9 +307,9 @@
         run_npm run lint -- --fix
         run_npm run test
       fi
-      runcmd go mod tidy
+      runcmd $GO mod tidy
       runcmd env GO_DISCOVERY_TESTDB=true go test ./...
-      runcmd go test ./internal/secrets
+      runcmd $GO test ./internal/secrets
       ;;
 
     ci)
@@ -325,13 +326,13 @@
       echo "DONE: $((end-start)) seconds"
       echo "--------------------"
 
-      for pkg in $(go list ./...); do
+      for pkg in $($GO list ./...); do
         if [[ ${no_race[$pkg]} = '' ]]; then
           race="$race $pkg"
         fi
       done
-      runcmd env GO_DISCOVERY_TESTDB=true go test -race -count=1 $race
-      runcmd env GO_DISCOVERY_TESTDB=true go test -count=1 ${!no_race[*]}
+      runcmd env GO_DISCOVERY_TESTDB=true $GO test -race -count=1 $race
+      runcmd env GO_DISCOVERY_TESTDB=true $GO test -count=1 ${!no_race[*]}
       ;;
     lint) standard_linters ;;
     headers) check_headers ;;