diff --git a/src/examples/wasm/README.md b/src/examples/wasm/README.md index b80c33d35b..9b42ded095 100644 --- a/src/examples/wasm/README.md +++ b/src/examples/wasm/README.md @@ -2,10 +2,10 @@ The examples here show two different ways of using WebAssembly with TinyGo: -1. Defining and exporting functions via the `//export ` directive. See -[the export folder](./export) for an example of this. Additionally, the Wasm -module (which has a default value of `env`) can be specified using -`//go:wasm-module `. +1. Defining and exporting functions via the `//go:wasmimport ` directive. See +[the export folder](./export) for an example of this. This exports the function to the Wasm +module (which has a default value of `env`). You can also use the Go directive +`//go:export `. 1. Defining and executing a `func main()`. This is similar to how the Go standard library implementation works. See [the main folder](./main) for an example of this. diff --git a/src/examples/wasm/export/wasm.go b/src/examples/wasm/export/wasm.go index f5aaf8d2cf..fd517cc149 100644 --- a/src/examples/wasm/export/wasm.go +++ b/src/examples/wasm/export/wasm.go @@ -8,12 +8,12 @@ import ( func main() { } -//export add +//go:wasmimport add func add(a, b int) int { return a + b } -//export update +//go:wasmimport update func update() { document := js.Global().Get("document") aStr := document.Call("getElementById", "a").Get("value").String()