Using WASI
How to use TinyGo with the WebAssembly System Interface (WASI).
TinyGo is very useful for compiling programs for use on servers and other edge devices (WASI).
TinyGo programs can run in Extism, Fastly Compute@Edge, Fermyon Spin, tau, wazero and many other WebAssembly runtimes.
Here is a small TinyGo program for use within a WASI host application:
package main
//go:wasm-module yourmodulename
//export add
func add(x, y uint32) uint32 {
return x + y
}
// main is required for the `wasi` target, even if it isn't used.
func main() {}
To compile the above TinyGo program for use on any WASI runtime:
tinygo build -o main.wasm -target=wasi main.go