Closed xywf221 closed 4 years ago
Duplicate of https://github.com/wasmerio/wasmer/issues/924.
You've to declare the host functions (imported functions, aka imports) required by Go. Go WebAssembly toolchain is essentially targetting the Web for the moment, and a little jugglery is required to glue everything. Their approach (which is a valid one) is to required a set of imported functions.
Since this is more and more requested, I'm likely to implement this set of imported functions for all platforms (Go for PHP, Python, Ruby, C, C++, Rust etc.)…
Check this documentation to learn more about the PHP host function API: https://github.com/wasmerio/php-ext-wasm/tree/master/lib#function-wasm_new_instance, or https://github.com/wasmerio/php-ext-wasm/tree/master/lib#function-wasm_module_new_instance, or jump directly on this example: https://github.com/wasmerio/php-ext-wasm/blob/master/examples/imported_function.php.
Summary
I compiled a simple wasm instance with go, but it has exceptions.
Additional details
Go source code :
Compile command :
GOOS=js GOARCH=wasm go build -o go_main.wasm 8.go