Skip to content

componentize-go

Build WebAssembly components with Go

A Bytecode Alliance project

build status

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.

Installation

Using Go

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 --help

Alternatively:

go install github.com/bytecodealliance/componentize-go@latest

It should be accessible via PATH:

componentize-go --help

Download a release

You can download a specific release from the release page.

Build from source

Prerequisites

Run

cargo install --git https://github.com/bytecodealliance/componentize-go

Usage

Please reference the README.md and Makefile files in each of the directories in examples.

Build tags

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).

About

A tool that creates Go WebAssembly components.

Resources

Code of conduct

Contributing

Security policy

Stars

15 stars

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages