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 build flags #58021

Open
ottmar-zittlau opened this issue Jan 15, 2023 · 2 comments
Open

x/tools/gopls: filter -o from build flags #58021

ottmar-zittlau opened this issue Jan 15, 2023 · 2 comments
Labels
gopls/metadata Issues related to metadata loading in gopls gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ottmar-zittlau
Copy link

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

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

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

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

    • 1.74.3
      97dec172d3256f8ca4bfb2143f3f76b503ca0534
      x64
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.37.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    Checking configured tools....
    GOBIN: undefined
    toolsGopath:
    gopath: /home/oz/go
    GOROOT: /opt/go

    go: /usr/local/bin/go: go version go1.19.5 linux/amd64

    gotests: not installed
    gomodifytags: not installed
    impl: not installed
    goplay: not installed
    dlv: not installed
    staticcheck: not installed
    gopls: /home/oz/go/bin/gopls (version: v0.11.0 built with go: go1.19.5)

go env
Workspace Folder (GoTestProgram): /mnt/c/Users/torst/git/blog/GoTestProgram
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oz/.cache/go-build"
GOENV="/home/oz/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/oz/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/oz/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/mnt/c/Users/oz/git/blog/GoTestProgram/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2326393920=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

{
"go.buildFlags": [
"-o=../build"
]
}

Describe the bug

I'd like to change the output directory by specifiying a build flag.
It works as expected, but VS Code always displays the following error:

Error loading workspace: packages.Load error: 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.

This looks similar to the issue https://github.com/golang/vscode-go/issues/2248 - however, there, that error was justified, because the build flag was actually invalid. Here, the command does what it's supposed to do, but still displays an error.

Maybe it's relevant to mention that I'm using VS Code on Windows and Go in the WSL.

Steps to reproduce the behavior:

  1. Setup build flags specifying an output directory in the settings.json.
  2. Run build within VS Code using the "Go: Build Workspace" command

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

@findleyr
Copy link
Contributor

In general, it shouldn't be necessary to set -o, but we should filter this out in gopls (I believe there is precedent for doing this -- I will take a look)

@findleyr findleyr self-assigned this Jan 19, 2023
@findleyr findleyr added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 19, 2023
@findleyr findleyr changed the title VS Code displays error when specifying output directory in build flags x/tools/gopls: filter -o from build flags Jan 26, 2023
@findleyr findleyr transferred this issue from golang/vscode-go Jan 26, 2023
@findleyr findleyr added this to the gopls/later milestone Jan 26, 2023
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jan 26, 2023
@findleyr findleyr modified the milestones: gopls/later, gopls/v0.13.0 Jan 27, 2023
@ottmar-zittlau
Copy link
Author

In general, it shouldn't be necessary to set -o, but we should filter this out in gopls (I believe there is precedent for doing this -- I will take a look)

Thanks a lot!

@findleyr findleyr removed their assignment Mar 30, 2023
@adonovan adonovan added the gopls/metadata Issues related to metadata loading in gopls label Aug 31, 2023
@findleyr findleyr modified the milestones: gopls/v0.14.0, gopls/v0.15.0 Oct 9, 2023
@findleyr findleyr modified the milestones: gopls/v0.15.0, gopls/v0.16.0 Jan 17, 2024
@findleyr findleyr modified the milestones: gopls/v0.16.0, gopls/v0.17.0 Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/metadata Issues related to metadata loading in gopls gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants