Go 1.25
This overview applies when the project's target Go version is at least 1.25.
Language
Do not introduce new syntax on the basis of Go 1.25; it makes no language changes that affect programs.
Tools and modules
- New capability:
ignoredirectives togo.modfor generated, vendored, or otherwise excluded directories that package patterns such as./...must skip. Remember that ignored directories remain in module zip files. - Available capability: the
workpackage pattern when a command should cover every package in the current module or workspace modules. go version -m -jsonis available when build information must be consumed programmatically, andgo doc -httpfor local browsable documentation.go vetcan catchsync.WaitGroup.Addcalls made from the wrong place and host/port strings assembled withfmt.Sprintf; replace the latter withnet.JoinHostPortfor IPv6 correctness.- Unsupported or discouraged: depend on an automatically added
toolchainline when thegocommand updates thegodirective; Go 1.25 no longer adds one.
Runtime and diagnostics
- Runtime behaviour: the runtime choose
GOMAXPROCSin containers unless the application has a measured reason to override it. On Linux it accounts for cgroup CPU bandwidth limits and periodically tracks changes. A manualGOMAXPROCSsetting disables these defaults; callruntime.SetDefaultGOMAXPROCSto restore them. runtime/trace.FlightRecordercan retain a bounded in-memory execution trace and snapshot recent activity when a rare event occurs.- Available capability:
GODEBUG=checkfinalizers=1while diagnosing stalled finalisers or cleanup queues. - Experimental option: the Green Tea collector only with
GOEXPERIMENT=greenteagc. Treat it as experimental and validate it against representative workloads.
Standard library
- Available capability:
testing/synctest.Testandtesting/synctest.Waitfor deterministic concurrent tests that benefit from virtual time and explicit quiescence. Do not depend on the earlier experimental API. - Modern alternative:
sync.WaitGroup.Gofor the common pattern of starting and tracking goroutines when no per-goroutine error result is required. net/http.CrossOriginProtectioncan reject unsafe cross-origin browser requests when Fetch Metadata or origin checks fit the service's CSRF model. Configure only the required origin or pattern bypasses.- Interface support:
io/fs.ReadLinkFSwhen a filesystem exposes symbolic links. This enables symlink-aware behaviour inarchive/tar.Writer.AddFS,os.CopyFS,os.DirFS,os.Root.FS, andtesting/fstest. - Modern alternative:
os.Rootoperations for filesystem work that must remain beneath a designated directory. reflect.TypeAssert[T]is the modern alternative to assertingValue.Interface()when converting a reflected value to a known Go type.- Available capability: the
crypto/ecdsaraw key parsing andBytesAPIs instead of assembling encodings throughcrypto/ellipticormath/big. - TLS 1.2 SHA-1 signatures are rejected, servers prefer their highest mutually supported protocol version, and malformed peer behaviour is rejected more strictly.
GODEBUG=tlssha1=1provides temporary compatibility.
Experimental JSON
- Experimental or compatibility option:
GOEXPERIMENT=jsonv2only for evaluation. Test existingencoding/jsonusers for compatibility, and useencoding/json/v2orencoding/json/jsontextonly while accepting that their APIs may change.
Testing and compatibility
- Behavioural requirement: an error immediately before using any accompanying result. Go 1.25 corrected delayed nil checks that could previously let invalid result use appear to succeed.
go build -asandetects leaked C allocations at process exit.ASAN_OPTIONS=detect_leaks=0disables that check.- Platform requirement: macOS 12 or later. Treat
windows/armas unavailable for forward-looking work because Go 1.25 is its final release. GOAMD64=v3and higher fuse multiply-add operations, which can alter exact floating-point results. An explicit conversion between multiplication and addition preserves unfused rounding when required.