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:
10
examples/basic/testdata/add.go
vendored
Normal file
10
examples/basic/testdata/add.go
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
//export add
|
||||
func add(x, y uint32) uint32 {
|
||||
return x + y
|
||||
}
|
||||
|
||||
// main is required for the `wasi` target, even if it isn't used.
|
||||
// See https://wazero.io/languages/tinygo/#why-do-i-have-to-define-main
|
||||
func main() {}
|
||||
BIN
examples/basic/testdata/add.wasm
vendored
BIN
examples/basic/testdata/add.wasm
vendored
Binary file not shown.
15
examples/basic/testdata/add.wat
vendored
15
examples/basic/testdata/add.wat
vendored
@@ -1,15 +0,0 @@
|
||||
(module
|
||||
;; Define the optional module name. '$' prefixing is a part of the text format.
|
||||
$wasm/math
|
||||
|
||||
;; add returns $x+$y.
|
||||
;;
|
||||
;; Notes:
|
||||
;; * The stack begins empty and anything left must match the result type.
|
||||
;; * export allows api.Module to return this via ExportedFunction("add")
|
||||
(func (export "add") (param $x i32) (param $y i32) (result i32)
|
||||
local.get $x ;; stack: [$x]
|
||||
local.get $y ;; stack: [$x, $y]
|
||||
i32.add ;; stack: [$x+$y]
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user