diff options
| author | Michael Matloob <matloob@golang.org> | 2024-08-29 14:11:15 -0400 |
|---|---|---|
| committer | Michael Matloob <matloob@golang.org> | 2024-08-29 20:16:26 +0000 |
| commit | ffb3e574012ce9d3d5193d7b8df135189b8a6671 (patch) | |
| tree | e885e1a4c6072abecbfb2a8355c270b7c5bd92d3 /src | |
| parent | 00c48ad6155a209841dbfb6154f650c622aaa10b (diff) | |
| download | go-ffb3e574012ce9d3d5193d7b8df135189b8a6671.tar.xz | |
cmd/go/testdata/script: add a test case for issue #68658
Test that go files with a //go:build fileVersion earlier than go1.21
don't downgrade past go1.21.
Fixes #68658
Change-Id: If16a1b3867ad2cfa8867e60995f7d1eb801306e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/609436
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/go/testdata/script/build_issue68658.txt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/build_issue68658.txt b/src/cmd/go/testdata/script/build_issue68658.txt new file mode 100644 index 0000000000..d0fcb3c44f --- /dev/null +++ b/src/cmd/go/testdata/script/build_issue68658.txt @@ -0,0 +1,31 @@ +# Test for issue #68658: In GOPATH mode, files with a //go:build fileVersion +# earlier than go1.21 should downgrade to go1.21 and no further. + +[short] skip 'requires build' + +env GO111MODULE=off +go build foo bar + +-- foo/main.go -- +//go:build go1.10 + +package p + +import "fmt" + +func main() { + var x any // any was added in Go 1.18 + fmt.Println(x) +} + +-- bar/main.go -- +//go:build go1.20 + +package p + +import "fmt" + +func main() { + y := max(1, 2) // max was added in Go 1.21 + fmt.Println(y) +} |
