diff --git a/examples/env/main.go b/examples/env/main.go new file mode 100644 index 0000000..9bc84b8 --- /dev/null +++ b/examples/env/main.go @@ -0,0 +1,14 @@ +//go:generate tinygo build -o main.wasm -target=wasi -scheduler=none main.go + +package main + +import ( + "fmt" + "os" +) + +func main() { + for _, v := range os.Environ() { + fmt.Fprintln(os.Stdout, v) + } +} diff --git a/examples/env/main.wasm b/examples/env/main.wasm new file mode 100644 index 0000000..e37de08 Binary files /dev/null and b/examples/env/main.wasm differ diff --git a/examples/print-env/main.go b/examples/print-env/main.go deleted file mode 100644 index bdf9cdb..0000000 --- a/examples/print-env/main.go +++ /dev/null @@ -1,23 +0,0 @@ -//go:generate tinygo build -o main.wasm -target=wasi -scheduler=none main.go - -package main - -import ( - "fmt" - "io" - "os" -) - -//export environment -func environment(size uint32) { - // Defensive: clear out any data that the user may have sent, - // even if we aren't expecting it. - defer io.Copy(io.Discard, os.Stdin) - - // Calmly print the environment to stdout - for _, v := range os.Environ() { - fmt.Fprintln(os.Stdout, v) - } -} - -func main() {} diff --git a/examples/print-env/main.wasm b/examples/print-env/main.wasm deleted file mode 100644 index e4e6995..0000000 Binary files a/examples/print-env/main.wasm and /dev/null differ