Skip to content

Commit

Permalink
docs/guides: some improvements to the webassembly section
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <ron@hybridgroup.com>
  • Loading branch information
deadprogram committed Apr 25, 2023
1 parent 08fbf1d commit 0c4ff18
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
7 changes: 7 additions & 0 deletions content/docs/guides/webassembly/_index.md
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).
---

30 changes: 30 additions & 0 deletions content/docs/guides/webassembly/wasi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
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

//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
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Using WebAssembly"
title: "Using WASM"
weight: 3
description: |
How to call WebAssembly from JavaScript in a browser.
Expand Down

0 comments on commit 0c4ff18

Please sign in to comment.