From df1f83f4e18c5fd969bf15bfe72b1e0012b00a9b Mon Sep 17 00:00:00 2001 From: deadprogram Date: Thu, 15 Feb 2024 16:22:16 +0100 Subject: [PATCH] examples: add example for use with wasm-unknown target Signed-off-by: deadprogram --- src/examples/hello-wasm-unknown/main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/examples/hello-wasm-unknown/main.go diff --git a/src/examples/hello-wasm-unknown/main.go b/src/examples/hello-wasm-unknown/main.go new file mode 100644 index 00000000..557f4a3c --- /dev/null +++ b/src/examples/hello-wasm-unknown/main.go @@ -0,0 +1,18 @@ +// this is intended to be used as wasm32-unknown-unknown module. +// to compile it, run: +// tinygo build -size short -o hello-unknown.wasm -target wasm-unknown -gc=leaking -no-debug ./src/examples/hello-wasm-unknown/ +package main + +var x int32 + +//go:wasmimport hosted echo_i32 +func echo(x int32) + +//go:export update +func update() { + x++ + echo(x) +} + +func main() { +}