This is a tool to convert a Go application to a WebAssembly component. It takes the following as input:
- a WIT file or directory
- the name of a WIT world defined in the above file or directory
- the directory containing a Go module which targets said world
The output is a component which may be run using e.g. wasmtime.
Requires Go 1.25.5+
Add the following to your go.mod file and run go mod tidy:
tool github.com/bytecodealliance/componentize-go
In the same directory as your go.mod file, you can interact with the tool:
go tool componentize-go --helpAlternatively:
go install github.com/bytecodealliance/componentize-go@latestIt should be accessible via PATH:
componentize-go --helpYou can download a specific release from the release page.
- Rust toolchain - Latest version
cargo install --git https://github.com/bytecodealliance/componentize-goPlease reference the README.md and Makefile files in each of the directories in examples.
When compiling your Go module, componentize-go passes go build the
componentizego_async build tag when the selected WIT world uses async
features (async functions, streams, or futures).
SDKs can use //go:build componentizego_async to select between WASI 0.2 and
WASI 0.3 implementations of an API at compile time.
Any -tags you specify via the GOFLAGS environment variable are merged with
the tags above (rather than being overridden by them).