Google has released Go 1.27. This release adds generic methods to the language for defining type parameters. Memory allocation in the runtime has also been revamped.
The new version is available for download from the project’s official download page. Go 1.27 affects virtually every part of the ecosystem: the language specification, the toolchain, and the runtime.
The most notable change is support for generic methods. A method may now declare its own type parameters, rather than being limited to the receiver’s type parameters.
In addition, a key in a struct literal can now be any valid field selector. This lets you initialize fields in nested or embedded structs directly. Function type inference has also been generalized to all assignment contexts. Generic functions now work without explicit type arguments in composite literals, type conversions, and channel sends.
Runtime and tooling
The runtime uses size-specialized memory allocation. This reduces the allocation cost for small objects under 80 bytes by up to 30 percent. For programs that perform a lot of allocation, this translates to approximately a 1 percent performance improvement. The goroutine leak profile in runtime/pprof is now generally available and automatically detects permanently blocked goroutines.
On the tooling side, ` go fix ` gains new modernizers: `atomictypes`, `embedlit`, `slicesbackward`, and `unsafefuncs`. `go doc ` now supports queries with version numbers, such as `go doc example.com/pkg@v1.2.3`. And `go mod tidy ` consolidates multiple `require` blocks in `go.mod` into the standard two-block structure.