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
This commit is contained in:
Ghanan Gowripalan
2023-02-13 16:49:39 -08:00
committed by gVisor bot
parent a66612ffc3
commit f3185ca575
+1 -1
View File
@@ -1,6 +1,6 @@
module gvisor.dev/gvisor
go 1.18
go 1.20
require (
github.com/BurntSushi/toml v1.2.1