mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 11:13:27 +00:00
docs: small corrections for README regarding wasm
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -48,20 +48,22 @@ Here is a small TinyGo program for use by a WASI host application:
|
|||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//go:wasm-module yourmodulename
|
//go:wasmexport add
|
||||||
//export add
|
|
||||||
func add(x, y uint32) uint32 {
|
func add(x, y uint32) uint32 {
|
||||||
return x + y
|
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
|
```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
|
## Installation
|
||||||
|
|||||||
Reference in New Issue
Block a user