GoLand 2024.3 Help

WebAssembly (Wasm)

WebAssembly (Wasm) is a binary code that you can run in a browser. GoLand supports generation of WASM files from GO files. You can read more about You can read more about WebAssembly in documentation at webassembly.org.

  1. Open settings Ctrl+Alt+S, and navigate to Go | Build Tags.

  2. From the OS list, select js.

  3. From the Arch list, select wasm.

  4. Click OK.

  5. Click Run | Edit Configurations on the main toolbar.

  6. Click Add New Configuration icon (The Add New Configuration icon) or press Alt+Insert.

  7. From the Run kind list, select File.

  8. In the Files field, add the name of the GO file that you want to execute (for example, main.go).

  9. Clear the Run after build checkbox.

  10. In the Environment field, click the Browse button at the end of the field.

    In the Environment Variables dialog, add two environment variables:

    • GOOS=js

    • GOARCH=wasm

  11. In the Go tool arguments field, replace the -i argument with -o main.wasm, where main.wasm is the name of the future WASM file.

  12. Click OK.

  13. Click the Run <configuration_name > icon or press Shift+F10. As the result, in the Project tool window a new WASM file is created.

    Create the WebAssembly project (Wasm)
Last modified: 11 October 2024