# The gotypesalias GODEBUG setting was introduced with Go 1.22 and removed # with Go 1.27 but the GODEBUG behavior of the tool chain is independent of # the module version; only the tool version matters (go.dev/issue/76163). cp go.mod.20 go.mod # Go 1.20 must accept the removed GODEBUG gotypesalias with default value go build -n godebugok.go ! stderr 'use of removed' # This also applies to go vet go vet godebugok.go ! stderr . # Go 1.20 must not accept the removed GODEBUG gotypesalias with old value ! go build -n godebugold.go stderr 'use of removed' ! go vet godebugold.go stderr 'use of removed' # If the GODEBUG setting is valid in the .mod file the build succeeds. cp go.mod.20.godebugok go.mod go build -n main.go ! stderr 'use of removed' # In this case, setting an invalid value in the .go file leads to build failure. ! go build -n godebugold.go stderr 'use of removed' # If the GODEBUG setting is invalid in the .mod file the build fails. cp go.mod.20.godebugold go.mod ! go build -n main.go stderr 'use of removed' # In this case, setting a valid value in the .go file does not remedy the failure. ! go build -n godebugok.go stderr 'use of removed' [short] skip # Using a removed GODEBUG with old value in the environment causes panic at startup. cp go.mod.20 go.mod env GODEBUG=gotypesalias=0 ! go run printgodebug.go stderr 'removed GODEBUG gotypesalias set to old value' # Using a removed GODEBUG with default value in the environment is ok. env GODEBUG=gotypesalias=1 go run printgodebug.go stdout gotypesalias=1 # Setting a removed GODEBUG with old value in the environment during runtime is not guarded against. go run setgodebug.go stdout gotypesalias=0 -- go.mod.20 -- go 1.20 module m -- go.mod.20.godebugok -- go 1.20 module m godebug gotypesalias=1 -- go.mod.20.godebugold -- go 1.20 module m godebug gotypesalias=0 -- main.go -- package main func main() {} -- godebugok.go -- //go:debug gotypesalias=1 package main func main() {} -- godebugold.go -- //go:debug gotypesalias=0 package main func main() {} -- printgodebug.go -- package main import "fmt" import "os" func main() { fmt.Println(os.Getenv("GODEBUG")) } -- setgodebug.go -- package main import "fmt" import "os" func main() { os.Setenv("GODEBUG", "gotypesalias=0") fmt.Println(os.Getenv("GODEBUG")) }