From b1eaeb6ac62c6de9becf7a919034759a024d535b Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 19 Sep 2023 18:31:22 -0700 Subject: [PATCH] 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. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a6ca526ba..6c526f67b 100644 --- a/Makefile +++ b/Makefile @@ -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")