Skip to content

docs: fix WASI guide example to use //go:wasmexport - #512

Open
0pcom wants to merge 1 commit into
tinygo-org:devfrom
0pcom:wasi-guide-wasmexport
Open

docs: fix WASI guide example to use //go:wasmexport#512
0pcom wants to merge 1 commit into
tinygo-org:devfrom
0pcom:wasi-guide-wasmexport

Conversation

@0pcom

@0pcom 0pcom commented Sep 5, 2026

Copy link
Copy Markdown

Fixes tinygo-org/tinygo#5572.

The "Using WASI" guide's example uses //go:wasmimport on a function with a body, which fails to compile on current TinyGo:

main.go:4:6: can only use //go:wasmimport on declarations

//go:wasmimport declares a host function (and is only valid on body-less declarations). What the example defines is a function for the host to call, which is //go:wasmexport.

Verified with tinygo 0.41.1: the corrected example compiles for GOOS=wasip1 GOARCH=wasm, and the current one fails with exactly the error reported in the issue.

//go:wasmimport declares a host function and is only valid on
declarations without a body, so the example fails to compile:

    main.go:4:6: can only use //go:wasmimport on declarations

The example defines a function for the host to call, which is
//go:wasmexport.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example "Using WASI" doesn't compile

1 participant