This adds an experimental package gojs which implements the host side of Wasm compiled by GOARCH=wasm GOOS=js go build -o X.wasm X.go This includes heavy disclaimers, in part inherited by Go's comments https://github.com/golang/go/blob/go1.19/src/syscall/js/js.go#L10-L11 Due to this many will still use TinyGo instead. That said, this is frequently asked for and has interesting features including reflection and HTTP client support. Signed-off-by: Adrian Cole <adrian@tetrate.io>
25 lines
497 B
Go
25 lines
497 B
Go
package gojs_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/tetratelabs/wazero"
|
|
"github.com/tetratelabs/wazero/internal/testing/require"
|
|
)
|
|
|
|
func Test_argsAndEnv(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
stdout, stderr, err := compileAndRun(testCtx, "argsenv", wazero.NewModuleConfig().
|
|
WithEnv("c", "d").WithEnv("a", "b"))
|
|
|
|
require.EqualError(t, err, `module "" closed with exit_code(0)`)
|
|
require.Zero(t, stderr)
|
|
require.Equal(t, `
|
|
args 0 = test
|
|
args 1 = argsenv
|
|
environ 0 = c=d
|
|
environ 1 = a=b
|
|
`, stdout)
|
|
}
|