GCP – Announcing Wasm support in Go 1.24
Earlier this week, we released Go 1.24, the latest version of Google’s open-source programming language for productively building scalable, production-ready backend and cloud-based systems.
There’s a lot to love about Go 1.24, including support for post-quantum cryptography, a weak pointer implementation, and substantial performance improvements to the Go runtime. Go 1.24 also significantly expands its capabilities for WebAssembly (Wasm), a binary instruction format that provides for the execution of high-performance, low-level code at speeds approaching native performance. With a new `go:wasmexport` compiler directive and the ability to build a reactor for the WebAssembly System Interface (WASI), developers can now export functions from their Go code to Wasm — including in long-running applications — fostering deeper integrations with Wasm hosts and unlocking new possibilities for Go-based Wasm applications.
These additions represent a significant step forward in Go’s Wasm story. For some types of applications, like those running at the edge, Wasm is critical to serving performance-critical use cases. Now, developers can leverage Go’s signature capabilities to ensure that these use cases are also scalable, secure, and production-ready.
- aside_block
- <ListValue: [StructValue([(‘title’, ‘Try Google Cloud for free’), (‘body’, <wagtail.rich_text.RichText object at 0x3eb7c2e44790>), (‘btn_text’, ‘Get started for free’), (‘href’, ‘https://console.cloud.google.com/freetrial?redirectPath=/welcome’), (‘image’, None)])]>
How does it work?
Go first added support for compiling to Wasm in Go 1.11 via the `js/wasm` port, and added a new port for the WASI preview 1 syscall API in Go 1.21. Now, with Go 1.24, the new `go:wasmexport` compiler directive makes Go functions accessible to a Wasm host, enabling the host to call into a Go application like a plugin or other extension mechanism. And, with the new WASI reactor build flag, a Go application remains live after its initialization function finishes, helping to ensure that exported functions remain callable without requiring reinitialization — an important feature in long-running applications or services.
For more details, be sure to check out this post from the Go blog and read more in the Go docs.
Run Wasm at the edge with Google Cloud
Starting today, you can now run Go compiled Wasm plugins for applications built on Google Cloud at the edge. To do so, you need to leverage Service Extensions with Google Cloud’s Application Load Balancers. Service Extensions allows you to run your own custom code directly in the request/response path in a fully managed Google environment with optimal latency, so you can customize load balancers to meet your business requirements. All you need to do is provide the code — Google Cloud manages the rest.
To get started with Service Extensions plugins and Go, take a look at our growing samples repository with a local testing toolkit and follow our quickstart guide in the documentation.
Read More for the details.