WebAssembly (Wasm)
WebAssembly (Wasm) is a binary format that you can run in a browser. IntelliJ IDEA supports generating WASM files from GO source files. To learn more, refer to the official WebAssembly documentation.
Open settings Ctrl+Alt+S, and navigate to
.From the OS list, select js.
From the Arch list, select wasm.
Click OK.
On the main toolbar, click
.Click the Add New Configuration icon (
) or press Alt+Insert.
From the Run kind list, select File.
In the Files field, add the name of the GO file you want to run (for example,
main.go
).Clear the Run after build checkbox.
In the Environment field, click the Browse button at the end of the field.
In the Environment Variables dialog, add the following environment variables:
GOOS=js
GOARCH=wasm
In the Go tool arguments field, replace the
-i
argument with-o main.wasm
, wheremain.wasm
is the name of the output WASM file.Click OK.
Click the Run <configuration_name> icon or press Shift+F10.
As a result, a new WASM file appears in the Project tool window.