This example implements a Go-based adding component example from the Component Model Book with the washCloud Shell (wash) CLI. The repo includes:
add.go- The Go code for the componentwit/world.wit- The WebAssembly Interface Type (WIT) file defining theaddinterfacewasmcloud.toml- A TOML file defining metadata and configuring the build process forwash build
Clone the repo and wash build from the project repo:
wash buildThis will generate bindings in the gen directory and create a Wasm binary in the build directory. (Actually, it will create two binaries, but for our purposes we're only interested in the final output, adder_s.wasm.)
Once the component is built, use wash inspect to view the component's imports and exports:
wash inspect --wit ./build/adder_s.wasmpackage root:component;
world root {
import wasi:io/[email protected];
import wasi:io/[email protected];
import wasi:cli/[email protected];
import wasi:cli/[email protected];
import wasi:cli/[email protected];
import wasi:clocks/[email protected];
import wasi:filesystem/[email protected];
import wasi:filesystem/[email protected];
export docs:adder/[email protected];
}We're exporting the add function.