What Is New in Go 1.25
| Category | Key Changes |
|---|---|
| Language | No changes to the language specification |
| Tooling | New go tool covdata command for coverage analysis |
| Runtime | Garbage collector pacing improvements, memory limit soft memory limit |
| Libraries | New math/rand/v2 package, new functions in cmp, maps, slices, iter |
| Ports | New wasip1 port for WebAssembly System Interface, RISC-V 64 port now supported on FreeBSD and OpenBSD |
What are the major tooling improvements?
The standout tooling addition is the new go tool covdata command. This tool gives you direct programmatic access to raw code coverage data files generated during testing. You can merge, subtract, and summarize coverage profiles without needing to re-run your tests.
In practice, this is a huge win for large codebases with complex integration test suites. You can now generate a single coverage profile from multiple test runs across different environments and analyze them together. It provides much finer control over how you collect and interpret your coverage metrics.
How has the garbage collector evolved?
Go 1.25 refines the garbage collector's pacing mechanism, particularly when running near the GOMEMLIMIT soft memory limit. The runtime now does a better job of balancing memory usage against garbage collection CPU costs to avoid throttling your application.
This matters because it makes the soft memory limit more predictable and useful in production. The GC will work harder to stay under the limit you set, which can help prevent your containers from getting killed by the kernel's OOM killer in memory-constrained environments like Kubernetes.
What's new in the standard library?
The headline addition is the new math/rand/v2 package. It cleans up the API from v1, removes the deprecated Read method, and uses higher-quality random number generation algorithms by default. The old v1 package remains available for existing code.
New functions in existing packages
cmp.Or: Returns the first non-zero value, useful for providing defaultsmaps.Values: Returns all values from a map in a sliceslices.Concat: Concatenates multiple slices into oneiter.Pullanditer.Pull2: Helpers for converting callback-based APIs into iterators
What platform support has been added?
Go 1.25 introduces the wasip1 port, which targets the WebAssembly System Interface. This lets you compile Go programs to run in WebAssembly environments outside the browser, such as WASI runtimes like Wasmtime or Wasmer.
The RISC-V 64 port (riscv64) now has tier 2 support on FreeBSD and OpenBSD, expanding the hardware platforms where you can deploy Go applications. This reflects the growing importance of RISC-V in the hardware ecosystem.
FAQ
Should I migrate from math/rand to math/rand/v2 immediately?
Not necessarily. The v1 package remains fully supported and will be maintained indefinitely. Migrate to v2 when you want to use the cleaner API or need the improved random number quality for your specific use case.
What's the practical benefit of the new go tool covdata?
It enables advanced code coverage workflows. You can combine coverage from unit tests and integration tests, subtract generated files from coverage reports, or create differential coverage between two versions of your codebase.
Does the GC change mean I should always set GOMEMLIMIT now?
The improvements make GOMEMLIMIT more reliable, but it's still optional. Set it when you're running in containers or environments with fixed memory boundaries to help the GC manage memory more effectively within those constraints.
When would I use the new wasip1 port?
Use it when targeting server-side WebAssembly runtimes, edge computing platforms that support WASI, or any environment where you want to run Go code isolated in a WebAssembly sandbox outside the browser.
What happens if I use cmp.Or with all zero values?cmp.Or returns the zero value of the type when all arguments are zero. This behavior makes it safe to use for providing default values without needing special case handling.