WebAssembly: update support file location
with https://golang.org/cl/604696
Updates golang/go#68024
Change-Id: Ia17d0beee2d2ba395788d9a2a7dea8ec88ba6f8f
GitHub-Last-Rev: 365f2d4cf059563382ef5a29441d2690d5f73af4
GitHub-Pull-Request: golang/wiki#22
Reviewed-on: https://go-review.googlesource.com/c/wiki/+/604119
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/WebAssembly.md b/WebAssembly.md
index 3390766..dc41784 100644
--- a/WebAssembly.md
+++ b/WebAssembly.md
@@ -31,6 +31,8 @@
> If you are on Windows, we suggest to follow this tutorial using a BASH emulation system such as Git Bash.
+> For Go 1.23 and earlier, the wasm support files needed in this article are located in `misc/wasm`, and the path should be replaced when performing operations with files such as `lib/wasm/wasm_exec.js`.
+
To compile a basic Go package for the web:
```go
@@ -63,7 +65,7 @@
Copy the JavaScript support file:
```sh
-cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .
+cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" .
```
Create an `index.html` file:
@@ -120,12 +122,12 @@
First, make sure Node is installed and in your `PATH`.
-Then, add `$(go env GOROOT)/misc/wasm` to your `PATH`.
+Then, add `$(go env GOROOT)/lib/wasm` to your `PATH`.
This will allow `go run` and `go test` find `go_js_wasm_exec` in a `PATH` search
and use it to just work for `js/wasm`:
```console
-$ export PATH="$PATH:$(go env GOROOT)/misc/wasm"
+$ export PATH="$PATH:$(go env GOROOT)/lib/wasm"
$ GOOS=js GOARCH=wasm go run .
Hello, WebAssembly!
$ GOOS=js GOARCH=wasm go test
@@ -137,15 +139,15 @@
seamlessly.
`go_js_wasm_exec` is a wrapper that allows running Go Wasm binaries in Node. By default,
-it may be found in the `misc/wasm` directory of your Go installation.
+it may be found in the `lib/wasm` directory of your Go installation.
If you'd rather not add anything to your `PATH`, you may also set the `-exec` flag to
the location of `go_js_wasm_exec` when you execute `go run` or `go test` manually.
```console
-$ GOOS=js GOARCH=wasm go run -exec="$(go env GOROOT)/misc/wasm/go_js_wasm_exec" .
+$ GOOS=js GOARCH=wasm go run -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" .
Hello, WebAssembly!
-$ GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/misc/wasm/go_js_wasm_exec"
+$ GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec"
PASS
ok example.org/my/pkg 0.800s
```
@@ -154,10 +156,10 @@
```console
$ GOOS=js GOARCH=wasm go build -o mybin .
-$ $(go env GOROOT)/misc/wasm/go_js_wasm_exec ./mybin
+$ $(go env GOROOT)/lib/wasm/go_js_wasm_exec ./mybin
Hello, WebAssembly!
$ GOOS=js GOARCH=wasm go test -c
-$ $(go env GOROOT)/misc/wasm/go_js_wasm_exec ./pkg.test
+$ $(go env GOROOT)/lib/wasm/go_js_wasm_exec ./pkg.test
PASS
ok example.org/my/pkg 0.800s
```