Skip to content

Example "Using WASI" doesn't compile #5572

Description

@pebbe

I run the example on https://tinygo.org/docs/guides/webassembly/wasi/

$ GOOS=wasip1 GOARCH=wasm tinygo build -o main.wasm main.go
main.go:4:6: can only use //go:wasmimport on declarations

tinygo version 0.41.1 linux/amd64 (using go version go1.26.5 and LLVM version 20.1.1)

main.go:

package main

//go:wasmimport yourmodulename 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() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions