From f3185ca575ec0e7feb21f3b8968cc0c2ea3143c3 Mon Sep 17 00:00:00 2001 From: Ghanan Gowripalan Date: Mon, 13 Feb 2023 16:45:52 -0800 Subject: [PATCH] Bump go version to 1.20 https://github.com/google/gvisor/commit/90f0ae3b59ed56d2064e619bfc1c7f51 introduced a change that made use of go 1.20 features with a polyfil through gohacks for go versions >= 1.13 but < 1.20. When building gVisor using a compiler with version 1.20, we get the following error when attempting to build from the root gVisor dir on the go branch: ``` $ git checkout go Already on 'go' Your branch is up to date with 'origin/go'. $ echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" Current branch: go $ GOROOT="$pwd" $PATH_TO_GO120_DIR/go version go version go1.20 linux/amd64 $ GOROOT="$pwd" $PATH_TO_GO120_DIR/go build -o testout ./runsc # gvisor.dev/gvisor/pkg/gohacks pkg/gohacks/string_go120_unsafe.go:27:7: unsafe.StringData requires go1.20 or later (-lang was set to go1.18; check go.mod) pkg/gohacks/string_go120_unsafe.go:38:9: unsafe.String requires go1.20 or later (-lang was set to go1.18; check go.mod) $ echo $? 1 $ ``` Bumping the go version to 1.20 in `go.mod` resolves this, without breaking go compilers < 1.20 thanks to the gohacks polyfil: ``` $ git checkout go Already on 'go' Your branch is up to date with 'origin/go'. $ echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" Current branch: go $ GOROOT="$pwd" $PATH_TO_GO120_DIR/go version go version go1.20 linux/amd64 $ GOROOT="$pwd" $PATH_TO_GO120_DIR/go build -o testout ./runsc $ echo $? 0 $ GOROOT="$pwd" $PATH_TO_GO119_DIR/go version go version go1.19.5 linux/amd64 $ GOROOT="$pwd" $PATH_TO_GO119_DIR/go build -o testout ./runsc $ echo $? 0 $ ``` While I am here, bump the go SDK version used to 1.20 as well. PiperOrigin-RevId: 509368541 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 26603ec95..cecad9184 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module gvisor.dev/gvisor -go 1.18 +go 1.20 require ( github.com/BurntSushi/toml v1.2.1