Skip to content

Commit ffb3e57

Browse files
committed
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 00c48ad commit ffb3e57

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Test for issue #68658: In GOPATH mode, files with a //go:build fileVersion
2+
# earlier than go1.21 should downgrade to go1.21 and no further.
3+
4+
[short] skip 'requires build'
5+
6+
env GO111MODULE=off
7+
go build foo bar
8+
9+
-- foo/main.go --
10+
//go:build go1.10
11+
12+
package p
13+
14+
import "fmt"
15+
16+
func main() {
17+
var x any // any was added in Go 1.18
18+
fmt.Println(x)
19+
}
20+
21+
-- bar/main.go --
22+
//go:build go1.20
23+
24+
package p
25+
26+
import "fmt"
27+
28+
func main() {
29+
y := max(1, 2) // max was added in Go 1.21
30+
fmt.Println(y)
31+
}

0 commit comments

Comments
 (0)