Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: filter -o from go list invocation #1561

Open
squeeze69 opened this issue Jun 4, 2021 · 4 comments
Open

x/tools/gopls: filter -o from go list invocation #1561

squeeze69 opened this issue Jun 4, 2021 · 4 comments
Assignees

Comments

@squeeze69
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go from the VS Code integrated terminal.

    • go version go1.16.5 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

    • golang.org/x/tools/gopls v0.6.11
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • Versione: 1.56.2 (user setup)
      Commit: 054a9295330880ed74ceaedda236253b4f39a335
      Data: 2021-05-12T17:13:13.157Z
      Electron: 12.0.4
      Chrome: 89.0.4389.114
      Node.js: 14.16.0
      V8: 8.9.255.24-electron.0
      Sistema operativo: Windows_NT x64 6.1.7601
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.25.1

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.
{
"settings": {
"go.toolsEnvVars": {
"GOOS": "js",
"GOARCH": "wasm",
"GO111MODULE":"off"
},
"go.buildFlags": ["-o='built/output.wasm'"]
}
}

Describe the bug

Starting vscode with a go project with a workspace including: "go.buildFlags": ["-o='built/output.wasm'"] the go extension complains that "go list" doesn't support the "-o" flag.
The error is:
Error loading workspace: err: exit status 2: stderr: flag provided but not defined: -o usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages] Run 'go help list' for details. : packages.Load error

A clear and concise description of what you expected to happen.
...I'd expect the workspace to load w/o any complain, since the "-o" flag should be used in "go build"

@stamblerre stamblerre transferred this issue from golang/vscode-go Jun 4, 2021
@stamblerre stamblerre changed the title wrong workspace error x/tools/gopls: filter -o from go list invocation Jun 4, 2021
@stamblerre stamblerre self-assigned this Jun 4, 2021
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/325889 mentions this issue: internal/gocommand: filter -o from build flags

@hyangah
Copy link
Contributor

hyangah commented Jun 8, 2021

@squeeze69 What is the goal of adding -o into the go.buildFlags? The build flags are used to build/vet/test every package in the project and I am afraid -o doesn't fit there. The vscode go extension doesn't run go build any longer, that means, even with the workaround cl/325889 tries to do, it will not do what you expect. I agree that the settings documentation needs to clarify this fact.

If your goal is to run go build and produce the output, I think VSCode's Task may be a better fit for the problem. https://code.visualstudio.com/docs/editor/tasks. It's unfortunate that VSCode doesn't support "Run task on save" feature natively so currently you may need to depend on third-party extensions, or manually invoke the build task (for example, if you place the go build task as the "build" kind, default task, you can trigger it with Cmd+Shift+B on mac). What do you think?

@squeeze69
Copy link
Author

Hi, it could be an interesting workaround, thanks, but the current settings were ok before a go plugin update (I really don't remember when it stopped working).

BTW, IMHO, every build flag accepted by the build command should be allowed, not a subset common to go list, etc... Maybe a filter would be enough? Or a new setting go.testBuildFlags which override go.buildFlags in test cases (only if present, of course)?

@hyangah
Copy link
Contributor

hyangah commented Jun 11, 2021

I admit it's confusing - -o isn't a build flag, but it is a go build command's flag.
For testing, there is go.testFlags.

@findleyr findleyr assigned hyangah and unassigned stamblerre Jun 11, 2021
@hyangah hyangah transferred this issue from golang/go Jun 11, 2021
@gopherbot gopherbot added this to the Untriaged milestone Jun 11, 2021
@hyangah hyangah modified the milestones: Untriaged, Backlog Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants