build: prep for Go 1.22 by using GOEXPERIMENT=loopvar for tests

In this commit, [we prep for some upcoming changes in
Go](https://go.dev/blog/loopvar-preview) by running our tests with
`GOEXPERIMENT=loopvar`. This changes the loop semantics to fix a common
bug where a scoping issue causes a variable to be re-used, which can
cause unintended bugs down the line.

If everything passes with this flag on, then we can keep it on, and also
rest a bit easier knowing that the compiler will fix a class of bugs
that would previously pop up for us.
This commit is contained in:
Olaoluwa Osuntokun
2023-09-19 18:31:22 -07:00
parent 91d910872d
commit b1eaeb6ac6

View File

@@ -23,7 +23,7 @@ COMMIT := $(shell git describe --tags --dirty)
GOBUILD := go build -v
GOINSTALL := go install -v
GOTEST := go test
GOTEST := GOEXPERIMENT=loopvar go test
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -name "*pb.go" -not -name "*pb.gw.go" -not -name "*.pb.json.go")