Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Add go.goos to the extension options #632

Closed
hickeng opened this issue Nov 19, 2016 · 7 comments
Closed

Add go.goos to the extension options #632

hickeng opened this issue Nov 19, 2016 · 7 comments

Comments

@hickeng
Copy link

hickeng commented Nov 19, 2016

Currently the only way I've found to set GOOS for the Go tools in vscode is to set the environment before launching the editor - this doesn't work well if you have multiple workspaces that may need different GOOS settings.

While I appreciate the prompt to ensure that the code at least compiles on multiple platforms, not all 3rd party packages do so and that causes real issues with guru and the other navigation tools.

@ramya-rao-a
Copy link
Contributor

@hickeng On the same line, wouldn't you also need GOARCH?
@mattetti You have any thoughts here?

@mattetti
Copy link
Contributor

It is a bit of an edge case but I agree that it would be a useful feature to have. @hickeng can you explain a bit more your edge case, are you trying to check that your code compiles properly against multiple os/arch targets?

@hickeng
Copy link
Author

hickeng commented Jan 17, 2017

@ramya-rao-a For completeness yes, but it's GOOS that's the most awkward currently.

@mattetti The multi-target case is definitely one that I hit, but it's not actually the one I experience on a daily basis.
I'm using Windows for my OS for various reasons but core portions of code I'm developing build only on Linux. It's easy enough to build that portion of the code in a VM or cross-compile but the Go tools are not happy in vscode. For example godefs cannot find call targets in the Linux only code. I have tried setting GOOS to linux in the past but never had it propagate to the tools unless I set it at a system level which causes other issues. I realize that I'd have issue navigating the Windows portions of the code if I change GOOS at a workspace level but the portions of the code that are not multi-platform are Linux so that's where the pain primarily presents.

@ramya-rao-a
Copy link
Contributor

Thanks @hickeng. This should be easy to do.

PRs are welcome if anyone wants to take a crack at this.

Hints:

  • Add a new configuration property in package.json
  • Update updateGoPathGoRootFromConfig which updates GOPATH and GOROOT from settings to include updating the GOOS as well. Probably rename the method as well :)

@ramya-rao-a
Copy link
Contributor

This is fixed by #932.

The update containing the fix will be out soon

@ramya-rao-a
Copy link
Contributor

Fix is out in the latest update (0.6.60)

@hickeng Can you add your env vars in the new setting go.toolsEnvVars and confirm if your issue is fixed?

@jackie-qiu
Copy link

@ramya-rao-a Thank you, "go.toolsEnvVars": {"GOOS" : "linux"}, that works for me.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants