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.lock b/wasm-go/.flox/env/manifest.lock new file mode 100644 index 0000000..69f929d --- /dev/null +++ b/wasm-go/.flox/env/manifest.lock @@ -0,0 +1,270 @@ +{ + "lockfile-version": 1, + "manifest": { + "version": 1, + "install": { + "go": { + "pkg-path": "go" + }, + "wasmtime": { + "pkg-path": "wasmtime" + } + }, + "vars": { + "GOARCH": "wasm", + "GOOS": "wasip1" + }, + "hook": {}, + "profile": {}, + "options": { + "systems": [ + "aarch64-darwin", + "aarch64-linux", + "x86_64-darwin", + "x86_64-linux" + ], + "allow": { + "licenses": [] + }, + "semver": {} + } + }, + "packages": [ + { + "attr_path": "go", + "broken": false, + "derivation": "/nix/store/m82cyrgfqssf9aqfas6nhlrppiw21yhl-go-1.23.2.drv", + "description": "Go Programming language", + "install_id": "go", + "license": "BSD-3-Clause", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "go-1.23.2", + "pname": "go", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "1.23.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "out": "/nix/store/35jikx2wg5r0qj47sic0p99bqnmwi6cn-go-1.23.2" + }, + "system": "aarch64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "go", + "broken": false, + "derivation": "/nix/store/fvhf2xd1fis6ris4dviqzvnipc7p5gj0-go-1.23.2.drv", + "description": "Go Programming language", + "install_id": "go", + "license": "BSD-3-Clause", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "go-1.23.2", + "pname": "go", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "1.23.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "out": "/nix/store/6bx6d90kpy537yab22wja70ibpp4gkww-go-1.23.2" + }, + "system": "aarch64-linux", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "go", + "broken": false, + "derivation": "/nix/store/a9jji6d0ic7ix8vjw888kmpgcgbkck1a-go-1.23.2.drv", + "description": "Go Programming language", + "install_id": "go", + "license": "BSD-3-Clause", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "go-1.23.2", + "pname": "go", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "1.23.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "out": "/nix/store/yi89mimkmw48qhzrll1aaibxbvllpsjv-go-1.23.2" + }, + "system": "x86_64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "go", + "broken": false, + "derivation": "/nix/store/k4sd1nf7nl549wcyx4z3g59sxd2h8xim-go-1.23.2.drv", + "description": "Go Programming language", + "install_id": "go", + "license": "BSD-3-Clause", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "go-1.23.2", + "pname": "go", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "1.23.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "out": "/nix/store/klw1ipjsqx1np7pkk833x7sad7f3ivv9-go-1.23.2" + }, + "system": "x86_64-linux", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "wasmtime", + "broken": false, + "derivation": "/nix/store/lkfz47y8pyvdmzn8drj1f965sckh92y3-wasmtime-25.0.2.drv", + "description": "Standalone JIT-style runtime for WebAssembly, using Cranelift", + "install_id": "wasmtime", + "license": "Apache-2.0", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "wasmtime-25.0.2", + "pname": "wasmtime", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "25.0.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "dev": "/nix/store/hxdxvj9lc3zwpivi9998q9kx7j4vrgrg-wasmtime-25.0.2-dev", + "out": "/nix/store/jrxzqnfm3fdh4rh6q0cfil7r9cwiwkx2-wasmtime-25.0.2" + }, + "system": "aarch64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "wasmtime", + "broken": false, + "derivation": "/nix/store/q1q2nf5ry8cxzpmh8ccdvg1zakg0126p-wasmtime-25.0.2.drv", + "description": "Standalone JIT-style runtime for WebAssembly, using Cranelift", + "install_id": "wasmtime", + "license": "Apache-2.0", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "wasmtime-25.0.2", + "pname": "wasmtime", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "25.0.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "dev": "/nix/store/sr83czmp16hj7znf96n4ilqncd7s9byk-wasmtime-25.0.2-dev", + "out": "/nix/store/gimn6kpqpgzvwih2hzm6pqphyfy7hc1y-wasmtime-25.0.2" + }, + "system": "aarch64-linux", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "wasmtime", + "broken": false, + "derivation": "/nix/store/d5jcwc2qadpq6piabcqbxfhrlmhd25y1-wasmtime-25.0.2.drv", + "description": "Standalone JIT-style runtime for WebAssembly, using Cranelift", + "install_id": "wasmtime", + "license": "Apache-2.0", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "wasmtime-25.0.2", + "pname": "wasmtime", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "25.0.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "dev": "/nix/store/y3dg5s92hbz1kcngh7x6vrvb9zw759pf-wasmtime-25.0.2-dev", + "out": "/nix/store/3sy3q7cm1s6kg0jvbl4dk43b0rbdl8cz-wasmtime-25.0.2" + }, + "system": "x86_64-darwin", + "group": "toplevel", + "priority": 5 + }, + { + "attr_path": "wasmtime", + "broken": false, + "derivation": "/nix/store/2hsjd0y8wsgmwmwy8m5dj6qbrnz0ry8g-wasmtime-25.0.2.drv", + "description": "Standalone JIT-style runtime for WebAssembly, using Cranelift", + "install_id": "wasmtime", + "license": "Apache-2.0", + "locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "name": "wasmtime-25.0.2", + "pname": "wasmtime", + "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev_count": 692963, + "rev_date": "2024-10-14T06:48:30Z", + "scrape_date": "2024-10-16T03:55:11Z", + "stabilities": [ + "unstable" + ], + "unfree": false, + "version": "25.0.2", + "outputs_to_install": [ + "out" + ], + "outputs": { + "dev": "/nix/store/q2x15x5gmnscdnqxnib2kvsjwjlxlf3v-wasmtime-25.0.2-dev", + "out": "/nix/store/6cvl86rivzga6pdd7ia994fwnwi9xj0x-wasmtime-25.0.2" + }, + "system": "x86_64-linux", + "group": "toplevel", + "priority": 5 + } + ] +} \ No newline at end of file diff --git a/wasm-go/.flox/env/manifest.toml b/wasm-go/.flox/env/manifest.toml new file mode 100644 index 0000000..d7a5aec --- /dev/null +++ b/wasm-go/.flox/env/manifest.toml @@ -0,0 +1,11 @@ +version = 1 +[install] +wasmtime.pkg-path = "wasmtime" +go.pkg-path = "go" + +[vars] +GOOS = "wasip1" +GOARCH = "wasm" + +[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