Redirects users to tested example (#791)
Rather than clutter both the README and home page with details that can drift and have caused maintenance, this directs users to the tested basic example. This also adds a FAQ entry about TinyGo's main, thanks to @basvanbeek for the help. Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -1,3 +1,36 @@
|
||||
## Basic example
|
||||
|
||||
This example shows how to use both WebAssembly and Go-defined functions with wazero.
|
||||
This example shows how to extend a Go application with an addition function
|
||||
defined in WebAssembly.
|
||||
|
||||
Ex.
|
||||
```bash
|
||||
$ go run add.go 7 9
|
||||
7 + 9 = 16
|
||||
```
|
||||
|
||||
### Compilation
|
||||
|
||||
wazero is a WebAssembly runtime, embedded in your host application. To run
|
||||
WebAssembly functions, you need access to a WebAssembly Binary (Wasm),
|
||||
typically a `%.wasm` file.
|
||||
|
||||
[add.wasm](testdata/add.wasm) was compiled from [add.go](testdata/add.go) with
|
||||
[TinyGo][1], as it is the most common way to compile Go source to Wasm. Here's
|
||||
the minimal command to build a `%.wasm` binary.
|
||||
|
||||
```bash
|
||||
cd testdata; tinygo build -o add.wasm -target=wasi add.go
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
* Many other languages compile to (target) Wasm including AssemblyScript, C,
|
||||
C++, Rust, and Zig!
|
||||
* The embedding application is often called the "host" in WebAssembly.
|
||||
* The Wasm binary is often called the "guest" in WebAssembly. Sometimes they
|
||||
need [imports](../../imports) to implement features such as console output.
|
||||
TinyGo's `wasi` target, requires [WASI][2] imports.
|
||||
|
||||
[1]: https://wazero.io/languages/tinygo
|
||||
[2]: https://wazero.io/specs/#wasi
|
||||
|
||||
Reference in New Issue
Block a user