Go Component SDK with Custom WIT
This example is a WebAssembly component that demonstrates how to use the wasmCloud Go Component SDK in conjunction with your own custom WIT interfaces.
You can find this application's custom interface in wit/world.wit:
interface invoker {
  call: func() -> string;
}📦 Dependencies
[!WARNING] Due to incompatibilities introduced in
wasm-toolsv1.226.0, a version ofwasm-tools<= 1.225.0 is required for running this example.You can install
wasm-toolsv1.225.0 from upstream releases, or usecargo(Rust toolchain) if installed to install1.225.0-- (i.e.cargo install --locked wasm-tools@1.225.0)
Before starting, ensure that you have the following installed in addition to the Go (1.23+) toolchain:
tinygofor compiling Go (always use the latest version)wasm-toolsfor Go bindings- wasmCloud Shell (
wash) for building and running the components and wasmCloud environment 
👟 Run the example
Clone the wasmCloud/go repository:
git clone https://github.com/wasmCloud/go.gitChange directory to examples/component/invoke:
cd examples/component/invokeIn addition to the standard elements of a Go project, the example directory includes the following files and directories:
build/: Target directory for compiled.wasmbinariesgen/: Target directory for Go bindings of interfaceswit/: Directory for WebAssembly Interface Type (WIT) packages that define interfacesbindings.wadge_test.go: Automatically generated test bindingswadm.yaml: Declarative application manifestwasmcloud.lock: Automatically generated lockfile for WIT packageswasmcloud.toml: Configuration file for a wasmCloud application
Build the component
We will build and deploy this example manually, since we will be using the wash call subcommand to interact with the application, requiring a stable identity to call. (As you gain experience with wasmCloud, you will likely want to use the wash dev subcommand to automate your development process.)
Build the component:
wash buildStart a wasmCloud environment
Start a local wasmCloud environment (using the -d/--detached flag to run in the background):
wash up -dDeploy the application
Deploy the component using the application manifest (wadm.yaml):
wash app deploy wadm.yamlTo ensure that the application has reached Deployed status, you can use wash app list:
wash app listInvoke the component
Once the application is deployed, you can call the component using the wash call subcommand, which invokes a function on a component:
wash call invoke_example-invoker example:invoker/invoker.callHello from the invoker!Clean up
You can delete an application from your wasmCloud environment by referring either to its application name (invoke-example) or the original application manifest:
wash app delete wadm.yamlStop your local wasmCloud environment:
wash downBonus: Calling when running with wash dev
When running with wash dev, wasmCloud uses a generated ID for the component. If you have jq installed,
you can run the following command to call the component:
wash call "$(wash get inventory -o json | jq -r '.inventories[0].components[0].id')" example:invoker/invoker.call
Hello from the invoker!📖 Further reading
For more on custom interfaces, see the Interface Developer Guide in the wasmCloud documentation.