-
Notifications
You must be signed in to change notification settings - Fork 646
Files with _GOOS suffix cause build & documentation issue #1848
Comments
Isnt this a tooling problem? We use tools like |
All the tools do appear to work, but is depended on the Specific GOOS at the time of their execution it appears. The go extention for vscode should be able to resolve this issue in one way or another. Even if it isn't default functionality, an option to turn it on would be nice. |
How are we to identify the files for which GOOS should be changed? Is it based on the file names? Is that a standard or something only https://github.com/kardianos/service uses? |
Excellent point. Definitely should have included this before. This functionality is standard in the Golang build system. Along with file suffixes, build comments can be included at the top of the file that introduce the same limitation.
|
Cool! I knew about build constraints when used as build tags, but wasnt aware of file names having a part to play as well. Ok, so in this case, do we need to make the change for only the tools that take the |
So in my testing altering the Parsing build constraint comments seems like a can of worms to me, and I'm not sure what the best approach would be to handle constraints outside of |
Ok, then we can do the below:
PRs are welcome.
|
For features that depend on individual files, the above approach would work. For example;
But what about features that work at a package level? Like build and vet? |
Behaving like the golang platform itself is the lowest friction option ; eval for the current platform you're running on only. If parameters are passed in (ENV or config) that override GOOS for compilation reasons, the plugin should respect this, but I wouldn't bother trying to manage it proactively. I wouldn't try to build a fancy "multi-GOOS"-aware set of functionality without better golang support from the tools themselves ( https://golang.org/cmd/go/#hdr-GOPATH_and_Modules ; gofmt ). |
Since the build/vet/lint on save feature is triggered from a file save, I guess I can use that file's name to determine if the GOOS value needs to be set |
I think that it will be very difficult to handle this correctly, particularly because it will be hard to debug cases where build tags are implicitly applied. I suggest that we delegate build tag handling to the underlying tools. After |
On giving this further thought, I agree with @stamblerre If we have features/commands not supported by the language server that need similar handling, they can be taken on a case to case basis |
Hover Information, Signature Help, Go to/Peek Definition, Find All References, Rename Symbol, and
Change All Occurrences all seem to be affected by this.
Current workaround:
This is a clunky solution, but also breaks the same features listed above for files using other os suffixes
env GOOS=linux code .
Alternative workaround:
Less clunky version of the above workaround, but still breaks the above features for files using other os suffixes
"go.toolsEnvVars": {"GOOS": "linux"}
Steps to Reproduce:
Is there some way to get vscode to handle these functions without overwriting the GOOS environment variable every time?
The text was updated successfully, but these errors were encountered: