The godebug directive in go.mod or go.work sets default GODEBUG environment variable values for a module or workspace, overriding toolchain defaults based on the Go version.
// In go.mod or go.work
godebug (
default=go1.21
panicnil=1
asynctimerchan=0
)
Alternatively, use //go:debug comments at the top of a main package source file to set defaults for that specific package:
//go:debug default=go1.21
//go:debug panicnil=1
package main
The default key specifies a Go version to inherit unspecified settings from, while other keys explicitly enable or disable specific behaviors like panicnil or asynctimerchan.