diff --git a/wasm-go/.flox/.gitignore b/wasm-go/.flox/.gitignore new file mode 100644 index 0000000..15d71a1 --- /dev/null +++ b/wasm-go/.flox/.gitignore @@ -0,0 +1,4 @@ +run/ +cache/ +lib/ +log/ diff --git a/wasm-go/.flox/env.json b/wasm-go/.flox/env.json new file mode 100644 index 0000000..368f26b --- /dev/null +++ b/wasm-go/.flox/env.json @@ -0,0 +1,4 @@ +{ + "name": "wasm-go", + "version": 1 +} diff --git a/wasm-go/.flox/env/manifest.toml b/wasm-go/.flox/env/manifest.toml new file mode 100644 index 0000000..5a2a736 --- /dev/null +++ b/wasm-go/.flox/env/manifest.toml @@ -0,0 +1,14 @@ +version = 1 +[install] +wasmtime.pkg-path = "wasmtime" +go.pkg-path = "go" + +[vars] +GOOS="wasip1" +GOARCH="wasm" + +[hook] +[profile] +[services] +[options] +systems = ["aarch64-darwin", "aarch64-linux", "x86_64-darwin", "x86_64-linux"] diff --git a/wasm-go/test.sh b/wasm-go/test.sh new file mode 100755 index 0000000..67a0a48 --- /dev/null +++ b/wasm-go/test.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -eo pipefail + +echo ' +package main + +import "fmt" + +func main() { + fmt.Println("Hello world!") +} +' > main.go + +go build -o main.wasm main.go + +ACTUAL="$(wasmtime main.wasm)" +EXPECTED="Hello world!" + +if [ "$ACTUAL" != "$EXPECTED" ]; then + echo "Error: 'wasmtime main.wasm' did not return '$EXPECTED'." + exit 1 +fi + +rm main.go main.wasm