From 42f5e55ed51c45cc51d22ca8dc685d203ce62f43 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Tue, 25 Feb 2025 20:04:23 +0100 Subject: [PATCH] docs: small corrections for README regarding wasm Signed-off-by: deadprogram --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e03b749bb..518dcdad1 100644 --- a/README.md +++ b/README.md @@ -48,20 +48,22 @@ Here is a small TinyGo program for use by a WASI host application: ```go package main -//go:wasm-module yourmodulename -//export add +//go:wasmexport add func add(x, y uint32) uint32 { return x + y } - -// main is required for the `wasip1` target, even if it isn't used. -func main() {} ``` -This compiles the above TinyGo program for use on any WASI runtime: +This compiles the above TinyGo program for use on any WASI Preview 1 runtime: ```shell -tinygo build -o main.wasm -target=wasip1 main.go +tinygo build -buildmode=c-shared -o add.wasm -target=wasip1 add.go +``` + +You can also use the same syntax as Go 1.24+: + +```shell +GOARCH=wasip1 GOOS=wasm tinygo build -buildmode=c-shared -o add.wasm add.go ``` ## Installation