aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authordeadprogram <[email protected]>2024-02-15 16:22:16 +0100
committerRon Evans <[email protected]>2024-02-15 17:54:18 +0100
commitdf1f83f4e18c5fd969bf15bfe72b1e0012b00a9b (patch)
tree4655e90f0b7be4a386e98a03d3570581f3230ace
parent5879d785a986ab980f96ec2acadea8465d5fb51a (diff)
downloadtinygo-df1f83f4e18c5fd969bf15bfe72b1e0012b00a9b.tar.gz
tinygo-df1f83f4e18c5fd969bf15bfe72b1e0012b00a9b.zip
examples: add example for use with wasm-unknown target
Signed-off-by: deadprogram <[email protected]>
-rw-r--r--src/examples/hello-wasm-unknown/main.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/examples/hello-wasm-unknown/main.go b/src/examples/hello-wasm-unknown/main.go
new file mode 100644
index 000000000..557f4a3c3
--- /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() {
+}