Repository: go
Issue: x/tools/gopls: filter -o from build flags
Labels: NeedsInvestigation,gopls,Tools,gopls/metadata

<!--
For asking questions, see:
- [Stack Overflow](https://stackoverflow.com/questions/tagged/go+visual-studio-code)
- [GitHub Discussions (Help)](https://github.com/golang/vscode-go/discussions/categories/help)
- [`#vscode` channel in Gophers Slack](https://invite.slack.golangbridge.org/messages/vscode)

Before filing an issue, please review our troubleshooting guides
* [Troubleshooting problems with debugging](https://github.com/golang/vscode-go/wiki/debugging#troubleshooting)
* [Troubleshooting other problems](https://github.com/golang/vscode-go/wiki/troubleshooting)

Please answer these questions before submitting your issue. Thanks!
-->

### What version of Go, VS Code & VS Code Go extension are you using?
<details><summary>Version Information</summary><br>

* 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"
	
</details>

### 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](url) - 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.