Skip to content

Instantly share code, notes, and snippets.

@esimov
Created July 4, 2022 09:28
Show Gist options
  • Save esimov/6bd0d2bdaeae42f6f6c51dcdcb85e502 to your computer and use it in GitHub Desktop.
Save esimov/6bd0d2bdaeae42f6f6c51dcdcb85e502 to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="utf-8" />
<script src="js/wasm_exec.js"></script>
<script type="text/javascript">
function fetchAndInstantiate(url, importObject) {
return fetch(url).then(response =>
response.arrayBuffer()
).then(bytes =>
WebAssembly.instantiate(bytes, importObject)
).then(results =>
results.instance
);
}
var go = new Go();
var mod = fetchAndInstantiate("lib.wasm", go.importObject);
window.onload = function () {
mod.then(function (instance) {
go.run(instance);
});
};
</script>
</head>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment