go - How to setup Goland (or any other jetbrains product) for WASM development with Golang - Stack Overflow

I’m trying to set up GoLand for Go development, specifically for compiling WebAssembly (WASM) files. I’

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744904506a4600171.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信