mirror of
https://github.com/golang/go
synced 2024-11-23 19:30:05 -07:00
f63250238b
This commit adds scripts for running the WebAssembly binaries that the Go compiler will produce. The script go_js_wasm_exec uses Node.js to run the binaries. Adding it to PATH will enable "go run" and "go test" to work for js/wasm without having to manually provide the -exec flag. See https://golang.org/cmd/go/#hdr-Compile_and_run_Go_program for more information. The web page wasm_exec.html is an example on how to run the same binaries in a web browser. Both scripts use wasm_exec.js as a shared library. Updates #18892 Change-Id: Ia4d9bea025957750baa0d0651243dc88f156f85d Reviewed-on: https://go-review.googlesource.com/103255 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
31 lines
636 B
HTML
31 lines
636 B
HTML
<!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.
|
|
-->
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Go wasm</title>
|
|
</head>
|
|
|
|
<body>
|
|
<script src="wasm_exec.js"></script>
|
|
<script>
|
|
async function loadAndCompile() {
|
|
let resp = await fetch("test.wasm");
|
|
let bytes = await resp.arrayBuffer();
|
|
await compile(bytes);
|
|
document.getElementById("runButton").disabled = false;
|
|
}
|
|
|
|
loadAndCompile();
|
|
</script>
|
|
|
|
<button onClick="console.clear(); run();" id="runButton" disabled>Run</button>
|
|
</body>
|
|
|
|
</html>
|