Back
Go 1.27 interactive tour: generic methods and post-quantum signatures
SiTech Team3 წთ. საკითხავი

Go 1.27 interactive tour: generic methods and post-quantum signatures

VictoriaMetrics published a hands-on tour of Go 1.27, whose headline is generic methods — plus size-specialized allocation, ML-DSA crypto, a standard uuid package and JSON v2 by default.

Go 1.27 is approaching release, and VictoriaMetrics has published an interactive tour of what is changing, with runnable examples for each feature. The article, written by Jesús Espino and dated 31 July, picks up a series started by Anton Zhiyanov, who wrote a tour for every release from Go 1.22 through Go 1.26 and has decided to stop; VictoriaMetrics says it is continuing the tradition.

Generic methods lead the release

The headline is a change to the type system: a method declaration may now declare its own type parameters, independent of the receiver’s, so a generic operation on a type can live as a method of that type instead of a package-level function. The tour’s example gives a Box container a Map method that turns an int box into a string box. One restriction remains — interfaces still cannot declare type-parameterized methods, and a generic method cannot be used to satisfy an interface. Two smaller ergonomic wins come with it: a key in a struct literal may now be any valid field selector, so a promoted field from an embedded struct can be set directly, and function type inference has been generalized to conversions and composite literals.

Performance: allocation, SIMD and the compiler

The compiler now generates calls to size-specialized memory allocation routines, cutting the cost of small allocations of under 80 bytes by up to 30%. The overall gain is expected to be around 1% in allocation-heavy programs, in exchange for about 60 KB of extra binary size, and can be disabled with a GOEXPERIMENT flag. An experimental portable SIMD package (GOEXPERIMENT=simd) exposes vector-size-agnostic types, and the standard library is already a customer: the Swiss Table map implementation reimplemented its hash functions on top of simd intrinsics.

Security and the standard library

Post-quantum signatures arrive as crypto/mldsa, implementing ML-DSA as specified in FIPS 204 in three parameter sets, and reaching crypto/x509 and the TLS 1.3 signature schemes. The standard library gains a uuid package per RFC 9562, where NewV7 produces time-ordered values useful for database keys. The long-awaited encoding/json/v2 graduates out of experiment: it is available without a build flag, and the classic encoding/json is now backed by the v2 implementation under the hood, with a GOEXPERIMENT to restore the old behaviour. strings and bytes gain CutLast, and Unicode support jumps from version 15 to 17.

Tooling and less visible work

Among tooling changes: go test now runs the stdversion vet check by default, go doc can fetch documentation at a specific module version, and go fix gains new modernizers. The tour also highlights work that is easy to miss — HTTP/2 is finally a real package instead of a generated 12,226-line file, HTTP/3 scaffolding has landed in unexported form, and unsanctioned //go:linkname use is harder.

SSiTech

SiTech — AI-powered web development

We build fast, modern websites and bring AI into real business workflows. Have a project or a question? We'd love to help.