blob: cc37ea73ce5a71ebebd7657a116d5187883db770 [file] [log] [blame]
<!doctype html>
Copyright 2018 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
<meta charset="utf-8">
<title>Go wasm</title>
<script src="wasm_exec.js"></script>
if (!WebAssembly.instantiateStreaming) { // polyfill
WebAssembly.instantiateStreaming = async (resp, importObject) => {
const source = await (await resp).arrayBuffer();
return await WebAssembly.instantiate(source, importObject);
const go = new Go();
let mod, inst;
WebAssembly.instantiateStreaming(fetch("test.wasm"), go.importObject).then((result) => {
mod = result.module;
inst = result.instance;
document.getElementById("runButton").disabled = false;
async function run() {
inst = await WebAssembly.instantiate(mod, go.importObject); // reset instance
<button onClick="run();" id="runButton" disabled>Run</button>