This week, Google released Go 1.24, their latest open-source programming language for building scalable, production-ready backend and cloud-based systems.
Go 1.24 supports post-quantum cryptography, improves runtime efficiency, and contains a weak pointer implementation. Go 1.24 also improves WebAssembly (Wasm), a binary instruction format that executes high-performance, low-level programs at native rates. Go developers may now export functions to Wasm, even in long-running applications, with the new go:wasmexport
compiler directive and WASI reactor creation. This promotes deeper integrations with Wasm hosts and opens up new possibilities for Go-based Wasm applications.
The plot of Go’s Wasm has advanced significantly with these additions. Wasm is essential to meeting performance-critical use cases for particular applications, such as those operating at the edge. Developers can now make sure that these use cases are secure, scalable, and production-ready by utilizing Go’s signature capabilities.
How does Go 1.24 work?
In Go 1.11, Go introduced the ability to compile to Wasm using the js/wasm
port. In Go 1.21, Go added a new port for the WASI preview 1 syscall API. With Go 1.24, a Wasm host can now access Go functions through the new go:wasmexport
compiler directive, allowing the host to call into a Go application like a plugin or other extension mechanism. Additionally, a Go application stays active after its initialization function completes with the new WASI reactor build flag, which helps to guarantee that exported functions can still be called without needing to be reinitialized a crucial feature in apps or services that run for a long time.
Run Wasm at the edge with Google Cloud
Applications developed on Google Cloud at the edge can now run Go-compiled Wasm plugins as of right now. You must use Google Cloud’s Application Load Balancers in conjunction with Service Extensions to accomplish this. You can adapt load balancers to your business needs by using Service Extensions, which let you run your own custom code right in the request/response path in a fully controlled Google environment with optimal latency. Google Cloud handles the rest; all you have to do is supply the code.
WebAssembly
The binary instruction format for a stack-based virtual machine is called WebAssembly, or Wasm for short. Because Wasm is a portable compilation target for programming languages, client and server applications can be deployed online.
Quick and effective
The Wasm stack machine is intended to be encoded in a binary format that minimizes both size and load time. By utilizing common hardware capabilities across a variety of platforms, WebAssembly seeks to operate at native speed.
Secure
The memory-safe, sandboxed execution environment described by WebAssembly can even be used inside of pre-existing JavaScript virtual machines. WebAssembly will enforce the browser’s permissions and same-origin security restrictions when it is embedded in the web.
Debuggable and open
In order to facilitate manual debugging, testing, experimentation, optimization, learning, teaching, and program authoring, WebAssembly is made to be pretty-printed in a textual format. When accessing the Wasm modules’ source online, the text format will be utilized.
A component of the open web platform
The versionless, feature-tested, and backwards-compatible characteristics of the web are preserved with WebAssembly. The same Web APIs that are available from JavaScript will also be used by WebAssembly modules to access browser functionality and call into and out of the JavaScript context. Non-web embeddings are also supported by WebAssembly.
Overview of Go 1.24
Six months after the release of Go 1.23, the most recent version, Go 1.24, comes out. The majority of its modifications pertain to the way the toolchain, runtime, and libraries are implemented. As usual, the release upholds the compatibility guarantee of Go 1. Almost all Go applications should continue to compile and function normally.
Changes to the language
Generic type aliases are now fully supported by Go 1.24; a type alias can be parameterized similarly to a declared type. Details are in the language spec. GOEXPERIMENT=noaliastypeparams can be used to disable the feature for the time being, although Go 1.25 will remove the aliastypeparams setting.
Tools
Go command
Tool directives in go.mod are now used by Go modules to track executable dependencies. This eliminates the necessity for the earlier solution, which included adding tools as blank imports to a file with the standard name “tools.go.” In addition to the tools included with the Go distribution, these tools can now be used using the go tool command. Refer to the documentation for further details.
In addition to providing require directives, the new -tool flag for go get adds a tool directive to the current module for named packages.
All of the tools in the current module are referred to by the new tool meta-pattern. You can use the go install tool to install them into your GOBIN directory or the go get utility to upgrade them all.
The Go build cache now contains executables produced by go run as well as the updated go tool behavior. This increases the speed of subsequent executions at the cost of expanding the cache. Refer to #69290.
The -json flag, which reports build output and failures as structured JSON output on standard output, is now accepted by the go build and go install commands. See go help buildjson for information on the reporting format.
Additionally, go test -json now interleaves test result JSON with build output and errors in JSON. These are identified by new Action types, although you can use GODEBUG setting gotestjsonbuildtext=1 to go back to the text build output if they cause issues in a test integration system.
A versatile method for authenticating private module fetches is offered by the new GOAUTH environment variable. For further details, see go help goauth.
The version of the main module is now set in the compiled binary by the go build command according to the commit and/or version control system tag. If there are changes that have not been committed, a +dirty suffix will be added. To remove version control information from the binary, use the -buildvcs=false flag.
The toolchain selection process of the go command can be traced using the new GODEBUG parameter toolchaintrace=1.