Use the GODEBUG environment variable or //go:debug directives to override default Go runtime behaviors for compatibility or security testing. Set GODEBUG to a comma-separated list of key=value pairs in your shell before running the program, or add //go:debug comments at the top of your main package source files to compile specific settings into the binary.
export GODEBUG=http2client=0,panicnil=1
go run main.go
For a permanent change in your module, add a godebug block to your go.mod file (Go 1.23+) or use //go:debug directives in your source code:
//go:debug panicnil=1
//go:debug http2client=0
package main
import "fmt"
func main() {
fmt.Println("Running with custom GODEBUG settings")
}
Verify the effective settings for your package using go list -f '{{.DefaultGODEBUG}}' ./....