GoLand 2019.3 Help

Creating a WebAssembly (Wasm) project

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 WebAssembly at the official WebAssembly website.

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

  2. From the OS list, select js.

  3. From the Arch list, select wasm.

  4. Click Add configuration on the main toolbar.

  5. Click Add New Configuration icon The Add New Configuration icon or press Alt+Insert.

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

  7. Clear the Run after build checkbox.

  8. In the Environment field, click the folder icon (The Click or press Shift+Enter icon).

  9. In the Environment Variables dialog, add two environment variables:

    • GOOS=js
    • GOARCH=wasm
  10. 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.

  11. Click OK.

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

Last modified: 23 March 2020