Issues with Wasm and Go 1.16+

Hi guys,
I have some issues trying to run an Wasm example with Go 1.16. The code bellow works with Go 1.13 but not with Go 1.16 (on Ubuntu with Chrome 89).

The go file:

import "syscall/js"

func main() {
	doc := js.Global().Get("document")
	doc.Call("getElementById", "hello").Set("innerHTML", "Hello Wasm!")
}

The html file:

<html>
<head>
<meta charset="utf-8"/>
<script src="wasm_exec.js"></script>
<script>
  const go = new Go();
	WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) => {
		go.run(result.instance);
	});
</script>
</head>
<body>
    <h2>WebAssembly content</h2>
    <div id="hello"></div>
</body>
</html>

Execution environment:

cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .
GOOS=js GOARCH=wasm go build -o main.wasm
python3 -m http.server

Browser console log error:

Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #1 module=“go” function=“runtime.resetMemoryDataView” error: function import requires a callable
Promise.then (async)
(anonymous) @ (index):7

I’ll appreciate any idea.
Thanks,

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.