Documentation
¶
Overview ¶
examples/wasm_plugin/plugin/fib.go A WebAssembly plugin for Fibonacci calculation.
IMPORTANT: This MUST be built with TinyGo, not standard Go!
Build with TinyGo:
tinygo build -o fib.wasm -target=wasi fib.go
Standard Go's GOOS=wasip1 does NOT work for plugins because:
- When main() returns, Go calls proc_exit(0) which closes the module
- Even with select{} in main, there's a runtime check that prevents exported functions from being called until _start completes
TinyGo uses a different architecture that allows exported functions to remain callable after initialization.
Click to show internal directories.
Click to hide internal directories.