Avoid common Go anti-patterns like using panic(nil), ignoring GODEBUG settings, or misusing archive/tar formats by leveraging Go's built-in compatibility controls and strict type checking. Use //go:debug directives in your source files or godebug blocks in go.mod to explicitly control behavior changes like panicnil or http2client across toolchain versions. For example, to restore pre-Go 1.21 panic(nil) behavior in a Go 1.21+ project, add the following to your go.mod:
godebug (
default=go1.21
panicnil=1
)
Alternatively, set the environment variable GODEBUG=panicnil=1 before running your program to override defaults at runtime without changing source code.