This updates our examples to the latest SDKs as particularly this can help reveal issues around fan-out stats. Signed-off-by: Adrian Cole <adrian@tetrate.io>
TinyGo allocation example
This example shows how to pass strings in and out of a Wasm function defined
in TinyGo, built with tinygo build -o greet.wasm -scheduler=none -target=wasi greet.go
$ go run greet.go wazero
wasm >> Hello, wazero!
go >> Hello, wazero!
Under the covers, greet.go does a few things of interest:
- Uses
unsafe.Pointerto change a Go pointer to a numeric type. - Uses
reflect.StringHeaderto build back a string from a pointer, len pair. - Relies on TinyGo not eagerly freeing pointers returned.
See https://wazero.io/languages/tinygo/ for more tips.