47 lines
1.1 KiB
HTML
47 lines
1.1 KiB
HTML
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Go wasm</title>
|
|
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter&display=swap" rel="stylesheet">
|
|
<script src="wasm_exec.js"></script>
|
|
<script>
|
|
if (!WebAssembly.instantiateStreaming) {
|
|
// polyfill
|
|
WebAssembly.instantiateStreaming = async (resp, importObject) => {
|
|
const source = await (await resp).arrayBuffer();
|
|
return await WebAssembly.instantiate(source, importObject);
|
|
};
|
|
}
|
|
|
|
async function run() {
|
|
try {
|
|
const go = new Go();
|
|
|
|
const result = await WebAssembly.instantiateStreaming(
|
|
fetch("flappygopher.wasm"),
|
|
go.importObject
|
|
);
|
|
|
|
await go.run(result.instance);
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
}
|
|
|
|
run();
|
|
</script>
|
|
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body></body>
|
|
</html>
|