You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: WebAssembly.md
+10-8Lines changed: 10 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,8 @@ page.
31
31
32
32
> If you are on Windows, we suggest to follow this tutorial using a BASH emulation system such as Git Bash.
33
33
34
+
> 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`.
35
+
34
36
To compile a basic Go package for the web:
35
37
36
38
```go
@@ -63,7 +65,7 @@ support file, and a HTML page to connect everything together.
63
65
Copy the JavaScript support file:
64
66
65
67
```sh
66
-
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js".
68
+
cp "$(go env GOROOT)/lib/wasm/wasm_exec.js".
67
69
```
68
70
69
71
Create an `index.html` file:
@@ -120,12 +122,12 @@ rather than a browser, which can be useful for testing and automation.
120
122
121
123
First, make sure Node is installed and in your `PATH`.
122
124
123
-
Then, add `$(go env GOROOT)/misc/wasm` to your `PATH`.
125
+
Then, add `$(go env GOROOT)/lib/wasm` to your `PATH`.
124
126
This will allow `go run` and `go test` find `go_js_wasm_exec` in a `PATH` search
125
127
and use it to just work for `js/wasm`:
126
128
127
129
```console
128
-
$ export PATH="$PATH:$(go env GOROOT)/misc/wasm"
130
+
$ export PATH="$PATH:$(go env GOROOT)/lib/wasm"
129
131
$ GOOS=js GOARCH=wasm go run .
130
132
Hello, WebAssembly!
131
133
$ GOOS=js GOARCH=wasm go test
@@ -137,15 +139,15 @@ If you're running working on Go itself, this will also allow you to run `run.bas
137
139
seamlessly.
138
140
139
141
`go_js_wasm_exec` is a wrapper that allows running Go Wasm binaries in Node. By default,
140
-
it may be found in the `misc/wasm` directory of your Go installation.
142
+
it may be found in the `lib/wasm` directory of your Go installation.
141
143
142
144
If you'd rather not add anything to your `PATH`, you may also set the `-exec` flag to
143
145
the location of `go_js_wasm_exec` when you execute `go run` or `go test` manually.
144
146
145
147
```console
146
-
$ GOOS=js GOARCH=wasm go run -exec="$(go env GOROOT)/misc/wasm/go_js_wasm_exec".
148
+
$ GOOS=js GOARCH=wasm go run -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec".
147
149
Hello, WebAssembly!
148
-
$ GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/misc/wasm/go_js_wasm_exec"
150
+
$ GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec"
149
151
PASS
150
152
ok example.org/my/pkg 0.800s
151
153
```
@@ -154,10 +156,10 @@ Finally, the wrapper may also be used to directly execute a Go Wasm binary:
0 commit comments