Examples
Every page in this section walks through a program that exists in the repository and runs in CI.
Nothing here is a sketch: the guests are real .wasm files built by real toolchains, and the host
code is the file you can open beside it.
git clone https://github.com/samyfodil/wazy && cd wazymake test.examplesThat builds nothing and downloads nothing — the guest binaries are committed. Each tutorial also gives the command for its own example alone, and the toolchain command that produced its guest if you want to rebuild it.
Core WebAssembly
Section titled “Core WebAssembly”Start here if you have a .wasm and a Go program and want them talking. These examples use plain
core modules: the interface is integers and a linear memory, and both sides agree on the layout by
hand.
cat compiled by four toolchains.06AssemblyScript special importsAn AssemblyScript module not built against WASI still needs abort, trace and seed.07One instance per goroutineCompile once, then give each goroutine its own instance, its own memory, and no name.08Sharing a compilation cacheRun two runtimes off one compiled artifact, and keep it on disk so the next process starts warm.09Running a binary from the CLIRun a TinyGo command module under the wazy CLI and pass it arguments the guest reads with flag.The Component Model
Section titled “The Component Model”A component carries its own typed interface, so values cross as Go values and the hand-agreed layout above disappears. These four are the reason wazy exists as something other than a wazero fork.
CallAsync.11Bring your own WITDeclare a key-value interface and implement all four functions in Go — a resource, an option and a result included.12Building a componentProduce a WASI 0.2 component from Rust, TinyGo, Go, C, JavaScript or Python, with the real commands for each.13Composing componentsLink a provider and a consumer written in different languages into one .wasm, and run the pair with no host glue.If you would rather read than run
Section titled “If you would rather read than run”The guides cover the same ground as reference rather than walkthrough, and pkg.go.dev has the generated API documentation. Getting started is the five-minute version of tutorial 01.
Missing an example you wanted? Open an issue.