Before trying this example, the WasmEdge installation is required.
wget -qO- https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.14.0Then you can build this example.
# In the current directory.
$ go get github.com/second-state/WasmEdge-go/[email protected]
$ go buildThe pre-built WASM from rust is provided as "rust_host_func.wasm".
For building the WASM from the rust source, the following steps are required:
- Install the rustc and cargo.
- Install the target
wasm32-wasifor rust.$ rustup target add wasm32-wasi
$ cd rust_host_func
$ cargo build --target wasm32-wasi --release
# The output WASM will be `target/wasm32-wasi/release/rust_host_func.wasm`../hostfunc rust_host_func.wasmThe standard output of this example will be the following:
Go: Args: [./hostfunc rust_host_func.wasm]
There are 78 'google' in source code of google.comIf you want to try this example in AOT mode, please follow the Wasm AOT example to compile the WASM file.