wa-lang.org/wazero@v1.0.2/examples/basic/README.md (about) 1 ## Basic example 2 3 This example shows how to extend a Go application with an addition function 4 defined in WebAssembly. 5 6 ```bash 7 $ go run add.go 7 9 8 7 + 9 = 16 9 ``` 10 11 ### Compilation 12 13 wazero is a WebAssembly runtime, embedded in your host application. To run 14 WebAssembly functions, you need access to a WebAssembly Binary (Wasm), 15 typically a `%.wasm` file. 16 17 [add.wasm](testdata/add.wasm) was compiled from [add.go](testdata/add.go) with 18 [TinyGo][1], as it is the most common way to compile Go source to Wasm. Here's 19 the minimal command to build a `%.wasm` binary. 20 21 ```bash 22 cd testdata; tinygo build -o add.wasm -target=wasi add.go 23 ``` 24 25 ### Notes 26 27 * Many other languages compile to (target) Wasm including AssemblyScript, C, 28 C++, Rust, and Zig! 29 * The embedding application is often called the "host" in WebAssembly. 30 * The Wasm binary is often called the "guest" in WebAssembly. Sometimes they 31 need [imports](../../imports) to implement features such as console output. 32 TinyGo's `wasi` target, requires [WASI][2] imports. 33 34 [1]: https://wazero.io/languages/tinygo 35 [2]: https://wazero.io/specs/#wasi