Go 1.24 (2025-02-11)
Go 1.24 was released in February 2025, six months after Go 1.23. Most changes are in the implementation of the toolchain, runtime, and libraries. Go 1.24 continues to uphold the Go 1 compatibility promise. Almost all Go programs are expected to continue to compile and run as before.
Language Changes
Go 1.24 now fully supports generic type aliases. Type aliases can be parameterized just like defined types. See the language specification for details. This feature can currently be disabled by setting GOEXPERIMENT=noaliastypeparams, but this setting will be removed in Go 1.25.
Toolchain
Go Command
-
Tool Dependency Management: Go modules can now track executable dependencies using the
tooldirective ingo.modand run those tools using thego toolcommand. This eliminates the previous workaround of using "tools.go" files. See the documentation for more information.- Added the
-toolflag togo getto add tool directives to the current module. - Added the
toolmeta-pattern to refer to all tools in the current module. You can usego get toolto upgrade all tools orgo install toolto install them to the GOBIN directory.
- Added the
-
Cache Improvements: Executables created by
go runand the newgo toolbehavior are now cached in the Go build cache, making repeated executions faster. See #69290. -
JSON Output:
- The
go buildandgo installcommands now accept the-jsonflag to report build output and failures in structured JSON format. Seego help buildjsonfor details. go test -jsonnow reports build output and failures in JSON format interleaved with test results. These are distinguished by a newActiontype. To restore text build output, set the GODEBUGgotestjsonbuildtext=1.
- The
-
Private Module Authentication: Added the
GOAUTHenvironment variable to provide a flexible way to authenticate private module fetches. Seego help goauthfor more information. -
Version Information: The
go buildcommand now sets the main module's version in the compiled binary based on version control system tags and/or commits. If there are uncommitted changes, a+dirtysuffix is appended. Use the-buildvcs=falseflag to omit version control information. -
Toolchain Tracing: Added the GODEBUG setting toolchaintrace=1 to trace the
gocommand's toolchain selection process.
Cgo
Cgo supports new annotations to improve runtime performance:
#cgo noescape cFunctionName: Tells the compiler that memory passed to the C function does not escape.#cgo nocallback cFunctionName: Tells the compiler that the C function does not call any Go functions.
See the cgo documentation for more information.
Cgo now better detects multiple incompatible declarations of C functions across files. For example, if f is declared as both void f(int) and void f(double), cgo reports an error instead of potentially generating incorrect call sequences for f(0). See #67699.
Objdump
The objdump tool now supports disassembly for the 64-bit LoongArch (GOARCH=loong64), RISC-V (GOARCH=riscv64), and S390X (GOARCH=s390x) architectures.
Vet
-
New
testsAnalyzer: Reports common mistakes in tests, fuzz tests, benchmarks, and examples, such as misformatted names, incorrect signatures, or examples documenting non-existent identifiers. Some of these mistakes can cause tests not to run. This analyzer is part of the analyzers run bygo test. -
printfAnalyzer Improvements: Now reports calls likefmt.Printf(s)wheresis a non-constant format string with no other arguments. Such calls are often mistakes becausesmay contain%symbols;fmt.Printshould be used instead. See #60529. This check is only applied when the language version (as specified by thegodirective in go.mod or//go:buildcomments) is at least Go 1.24 to avoid breaking CI when upgrading to the 1.24 toolchain. -
buildtagAnalyzer Improvements: Reports diagnostics when invalid Go major version build constraints are present in//go:builddirectives. For example,//go:build go1.23.1refers to a point release;//go:build go1.23should be used instead. See #64127. -
copylockAnalyzer Improvements: Reports diagnostics when variables declared in the three-clause "for" loop (e.g.,for i := iter(); done(i); i = next(i) { ... }) containsync.Locker(e.g.,sync.Mutex). Go 1.22 changed the behavior of such loops to create a new variable for each iteration, copying the value from the previous iteration; this copying is unsafe for locks. See #66387.
GOCACHEPROG
The cmd/go internal binary and test caching mechanism can now be implemented by a subprocess named by the GOCACHEPROG environment variable, which implements a JSON protocol between the cmd/go tool and the subprocess. This previously required GOEXPERIMENT. See the documentation for protocol details.
Runtime
The runtime includes several performance improvements, reducing average CPU overhead by 2–3%, depending on the application. These improvements include:
- New Map Implementation: A new built-in
mapimplementation based on Swiss Tables. - Efficient Memory Allocation: More efficient memory allocation for small objects.
- New Mutex Implementation: A new runtime internal mutex implementation.
The new map implementation and new mutex implementation can be disabled by setting GOEXPERIMENT=noswissmap and GOEXPERIMENT=nospinbitmutex at build time, respectively.
References
For more details, please refer to the official release notes: Go 1.24 Release Notes