go-wasm icon indicating copy to clipboard operation
go-wasm copied to clipboard

examples seem broken

Open maddyblue opened this issue 5 years ago • 3 comments

Both of the examples seem broken. I'm on go1.13.5. The caller example uses a non-existent FromBytes function. The http example errors with:

panic: Failed to instantiate the module:
    2 link errors: (1 of 2) Import not found, namespace: go, name: syscall/js.copyBytesToGo (2 of 2) Import not found, namespace: go, name: syscall/js.copyBytesToJS

in the BridgeFromFile function.

maddyblue avatar Jan 10 '20 21:01 maddyblue

If I use the main.wasm file from this repo it works. But if I compile it myself (from the examples/http-wasm directory):

GOOS=js GOARCH=wasm go build

then the above error occurs. How did you produce the .wasm files in this repo?

maddyblue avatar Jan 10 '20 21:01 maddyblue

@mjibson could you tell me the Go version you are using ? ATM, it only supports go 1.13 since there are breaking changes in next or previous versions of Go since WASM is not in Go1 compatibilty

vedhavyas avatar Jul 30 '20 12:07 vedhavyas

You can re build wasm like this

GOOS=js GOARCH=wasm go build -o main.wasm ./examples/function-wasm/...
GOOS=js GOARCH=wasm go build -o main.wasm ./examples/http-wasm/...

vedhavyas avatar Jul 30 '20 12:07 vedhavyas