admin管理员组

文章数量:1405613

I’m trying to set up GoLand for Go development, specifically for compiling WebAssembly (WASM) files. I’m running into an issue that I hope someone can help me with.

When I attempt to import the syscall/js package in my Go code, I receive the following error:

build constraints exclude all Go files in 'Ilusr/local/go/src/syscall/js'.

To resolve this, I added the following build constraint at the top of my Go file:

//go:build js && wasm

This change allowed me to bypass the error, but unfortunately, it led to a new problem: I no longer have access to GoLand's documentation and code suggestions. This is a significant setback for my development process as I rely heavily on these features for writing and navigating my code.

I’m trying to set up GoLand for Go development, specifically for compiling WebAssembly (WASM) files. I’m running into an issue that I hope someone can help me with.

When I attempt to import the syscall/js package in my Go code, I receive the following error:

build constraints exclude all Go files in 'Ilusr/local/go/src/syscall/js'.

To resolve this, I added the following build constraint at the top of my Go file:

//go:build js && wasm

This change allowed me to bypass the error, but unfortunately, it led to a new problem: I no longer have access to GoLand's documentation and code suggestions. This is a significant setback for my development process as I rely heavily on these features for writing and navigating my code.

Share Improve this question edited Mar 8 at 21:32 desertnaut 60.5k32 gold badges155 silver badges182 bronze badges asked Mar 8 at 2:49 Seyed AliSeyed Ali 335 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Configuring GoLand for WebAssembly (Wasm) projects

Initial project configuration

When you first open or start a WebAssembly project in GoLand, it won'’t understand the “syscall/js” package. That’s easily fixable, by changing the GOOS and GOARCH values in the project settings, as shown in the below screenshots.

The screenshot below shows how to access Settings on a Linux desktop. If you're using macOS, you'll probably need to access them through the standard macOS Preferences option. GoLand Wasm.

Configuring Run/Debug settings

With the initial project settings changed, you'll probably want to configure the Run/Debug settings next.

That will let you recompile the .wasm file by just launching Run (Shift+F10 on Linux).

Finished, your GoLand setup should now be complete.

Source: Go Wiki: Configuring GoLand for WebAssembly

本文标签: goHow to setup Goland (or any other jetbrains product) for WASM development with GolangStack Overflow