tinygo

command
v1.0.0-pre.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

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

Ex.

$ go run greet.go wazero
wasm >> Hello, wazero!
go >> Hello, wazero!

Under the covers, greet.go does a few things of interest:

  • Uses unsafe.Pointer to change a Go pointer to a numeric type.
  • Uses reflect.StringHeader to 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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL