@@ -40,21 +40,14 @@ $ wkg wit build
4040WIT package written to docs:adder@0.1.0.wasm
4141```
4242
43- The ` docs:adder@0.1.0.wasm ` file is a Wasm encoding of the WIT package. Next, we can generate the bindings for it:
44-
45- ``` console
46- $ go get go.bytecodealliance.org/cmd/wit-bindgen-go
47- $ go run go.bytecodealliance.org/cmd/wit-bindgen-go generate -o internal/ ./docs:adder@0.1.0.wasm
48- ```
49-
5043Now, create your Go project:
5144
5245``` console
5346$ mkdir add && cd add
5447$ go mod init example.com
5548```
5649
57- Next, we can generate the bindings for the ` add.wit ` file :
50+ Next, we can generate the bindings for the Wasm component :
5851
5952``` console
6053$ go get go.bytecodealliance.org/cmd/wit-bindgen-go
@@ -104,11 +97,11 @@ The `adder.exports.go` file contains the exported functions that need to be impl
10497package main
10598
10699import (
107- " example.com/internal/example/component/example "
100+ " example.com/internal/docs/adder/adder "
108101)
109102
110103func init () {
111- example .Exports .Add = func (x int32 , y int32 ) int32 {
104+ adder .Exports .Add = func (x int32 , y int32 ) int32 {
112105 return x + y
113106 }
114107}
@@ -127,7 +120,7 @@ We can build our component using TinyGo by specifying the wit-package to be `add
127120Under the hood, TinyGo invokes ` wasm-tools ` to embed the WIT file to the module and componentize it.
128121
129122``` console
130- $ tinygo build -target=wasip2 -o add.wasm --wit-package add.wit --wit-world adder main.go
123+ $ tinygo build -target=wasip2 -o add.wasm --wit-package docs:adder@0.1.0.wasm --wit-world adder main.go
131124```
132125
133126We now have an add component that satisfies our ` adder ` world, exporting the ` add ` function, which
0 commit comments