Skip to main content
Go reaches WebAssembly through TinyGo, which targets wasip2 directly. Bindings come from wit-bindgen-go, and the build bundles your WIT into a single package first.

Prerequisites

  • Go 1.23 or newer.
  • TinyGo — the standard go compiler does not emit WASI Preview 2 components.
  • wkg, wit-bindgen-go, and wasm-tools.
  • The Noorle CLI.
noorle plugin prepare installs everything this guide needs — Go, TinyGo, wit-bindgen-go, Cargo, wkg, wasmtime, and wasm-tools. To install the bindings generator on its own:

Layout

The interface

include wasi:cli/imports pulls in the standard CLI world, which is what gives the component environment access.

The implementation

wit-bindgen-go generates an Exports struct per world. You assign your function to the matching field in init(), and leave main() empty — the component is invoked through its exports, not through a main entry point.
Generated package paths follow your module path plus gen/, so the import prefix changes with the module line in go.mod. Outbound HTTP goes through the generated wasi:http/outgoing-handler bindings. Go’s net/http client does not work — the sandbox exposes WASI HTTP and no raw sockets.

go.mod

cm provides the Component Model value types — cm.Option, cm.List, and the rest — that the generated bindings use.

noorle.yaml

Same shape in every language. Full key-by-key reference: noorle.yaml.

Build

That runs the project’s build.sh, which bundles the WIT, regenerates bindings, and compiles:
-scheduler=none drops goroutine scheduling, and -opt=2 -no-debug is the release setting — together they keep the binary small. gen/ is regenerated on every build, so do not edit it.

Test locally

Deploy

Next