1 # The gotypesalias GODEBUG setting was introduced with Go 1.22 and removed
2 # with Go 1.27 but the GODEBUG behavior of the tool chain is independent of
3 # the module version; only the tool version matters (go.dev/issue/76163).
4 cp go.mod.20 go.mod
5
6 # Go 1.20 must accept the removed GODEBUG gotypesalias with default value
7 go build -n godebugok.go
8 ! stderr 'use of removed'
9
10 # This also applies to go vet
11 go vet godebugok.go
12 ! stderr .
13
14 # Go 1.20 must not accept the removed GODEBUG gotypesalias with old value
15 ! go build -n godebugold.go
16 stderr 'use of removed'
17
18 ! go vet godebugold.go
19 stderr 'use of removed'
20
21 # If the GODEBUG setting is valid in the .mod file the build succeeds.
22 cp go.mod.20.godebugok go.mod
23 go build -n main.go
24 ! stderr 'use of removed'
25
26 # In this case, setting an invalid value in the .go file leads to build failure.
27 ! go build -n godebugold.go
28 stderr 'use of removed'
29
30 # If the GODEBUG setting is invalid in the .mod file the build fails.
31 cp go.mod.20.godebugold go.mod
32 ! go build -n main.go
33 stderr 'use of removed'
34
35 # In this case, setting a valid value in the .go file does not remedy the failure.
36 ! go build -n godebugok.go
37 #stderr 'use of removed'
38
39 [short] skip
40
41 # GODEBUGs set in the environment are simply passed along by the go command.
42 cp go.mod.20 go.mod
43 env GODEBUG=gotypesalias=0
44 go run printgodebug.go
45 stdout gotypesalias=0
46
47 env GODEBUG=gotypesalias=1
48 go run printgodebug.go
49 stdout gotypesalias=1
50
51 -- go.mod.20 --
52 go 1.20
53 module m
54
55 -- go.mod.20.godebugok --
56 go 1.20
57 module m
58 godebug gotypesalias=1
59
60 -- go.mod.20.godebugold --
61 go 1.20
62 module m
63 godebug gotypesalias=0
64
65 -- main.go --
66 package main
67 func main() {}
68
69 -- godebugok.go --
70 //go:debug gotypesalias=1
71
72 package main
73 func main() {}
74
75 -- godebugold.go --
76 //go:debug gotypesalias=0
77
78 package main
79 func main() {}
80
81 -- printgodebug.go --
82 package main
83
84 import "fmt"
85 import "os"
86
87 func main() {
88 fmt.Println(os.Getenv("GODEBUG"))
89 }
90
View as plain text