-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs/guides: some improvements to the webassembly section
Signed-off-by: deadprogram <ron@hybridgroup.com>
- Loading branch information
1 parent
91d5dd3
commit b41f8b4
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: "WebAssembly" | ||
weight: 2 | ||
description: > | ||
TinyGo is very useful for compiling programs both for use in browsers (WASM) as well as for use on servers and other edge devices (WASI). | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: "Using WASI" | ||
weight: 3 | ||
description: | | ||
How to use TinyGo with the WebAssembly System Interface (WASI). | ||
--- | ||
|
||
TinyGo is very useful for compiling programs for use on servers and other edge devices (WASI). | ||
|
||
TinyGo programs can run in Fastly Compute@Edge (https://developer.fastly.com/learning/compute/go/), Fermyon Spin (https://developer.fermyon.com/spin/go-components), wazero (https://wazero.io/languages/tinygo/) and many other WebAssembly runtimes. | ||
|
||
Here is a small TinyGo program for use within a WASI host application: | ||
|
||
```go | ||
package main | ||
|
||
//go:wasm-module yourmodulename | ||
//export add | ||
func add(x, y uint32) uint32 { | ||
return x + y | ||
} | ||
|
||
// main is required for the `wasi` target, even if it isn't used. | ||
func main() {} | ||
``` | ||
|
||
To compile the above TinyGo program for use on any WASI runtime: | ||
|
||
```shell | ||
tinygo build -o main.wasm -target=wasi main.go | ||
``` |
2 changes: 1 addition & 1 deletion
2
content/docs/guides/webassembly.md → content/docs/guides/webassembly/wasm.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters