Repository: go
Issue: x/tools/gopls: validate that user build flags are actually flags
Labels: NeedsFix,gopls,Tools

### 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 windows/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.1
* Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command.
	- ```
        Workspace Folder (devTools): c:\dev\devTools
	    set GO111MODULE=
	    set GOARCH=amd64
	    set GOBIN=
	    set GOCACHE=C:\Users\cwolf\AppData\Local\go-build
	    set GOENV=C:\Users\cwolf\AppData\Roaming\go\env
	    set GOEXE=.exe
	    set GOEXPERIMENT=
	    set GOFLAGS=
	    set GOHOSTARCH=amd64
	    set GOHOSTOS=windows
	    set GOINSECURE=
	    set GOMODCACHE=C:\Users\cwolf\go\pkg\mod
	    set GONOPROXY=redacted
	    set GONOSUMDB=redacted
	    set GOOS=windows
	    set GOPATH=C:\Users\cwolf\go
	    set GOPRIVATE=redacted
	    set GOPROXY=https://proxy.golang.org,direct
	    set GOROOT=C:\Program Files\Go
	    set GOSUMDB=sum.golang.org
	    set GOTMPDIR=
	    set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
            set GOVCS=
	    set GOVERSION=go1.19.5
	    set GCCGO=gccgo
	    set GOAMD64=v1
	    set AR=ar
	    set CC=gcc
	    set CXX=g++
	    set CGO_ENABLED=1
	    set GOMOD=NUL
	    set GOWORK=c:\dev\devTools\go.work
	    set CGO_CFLAGS=-g -O2
	    set CGO_CPPFLAGS=
	    set CGO_CXXFLAGS=-g -O2
	    set CGO_FFLAGS=-g -O2
	    set CGO_LDFLAGS=-g -O2
	    set PKG_CONFIG=pkg-config
	    set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\cwolf\AppData\Local\Temp\go-build1196747904=/tmp/go-build -gno-record-gcc-switches
	```
I also had `GOWORK=` before, but that led to the same issue.
</details>

### Share the Go related settings you have added/edited

```json
"go.lintOnSave": "file",
"go.buildOnSave": "off",
"go.toolsManagement.autoUpdate": true,
"go.formatTool": "goimports",
"go.inlayHints.constantValues": true,
"go.testFlags": [
    "-v",
    "-timeout",
    "5m",
    // "-race"
],
"go.coverageDecorator": {
    "type": "highlight",
    "coveredHighlightColor": "rgba(64,128,128,0.5)",
    "uncoveredHighlightColor": "rgba(128,64,64,0.25)",
    "coveredGutterStyle": "blockgreen",
    "uncoveredGutterStyle": "blockred"
},
"go.coverMode": "atomic",
"go.languageServerExperimentalFeatures": {
    "diagnostics": false
},
"gopls": {
    "build.buildFlags": [ "integration" ]
},
```

### Describe the bug

#### A clear and concise description of what the bug is:

In my workspace folder I have a `go.work` file containing my relative module paths in that folder.
Still, I get the following persistent error notification:
```
Error loading workspace: packages.Load error: err: exit status 1: stderr: cannot find package "integration" in any of: 	C:\Program Files\Go\src\integration (from $GOROOT) 	C:\Users\cwolf\go\src\integration (from $GOPATH) cannot find package "-e" in any of: 	C:\Program Files\Go\src\-e (from $GOROOT) 	C:\Users\cwolf\go\src\-e (from $GOPATH) cannot find package "-f" in any of: 	C:\Program Files\Go\src\-f (from $GOROOT) 	C:\Users\cwolf\go\src\-f (from $GOPATH) cannot find package "{{context.ReleaseTags}}" in any of: 	C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT) 	C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH) cannot find package "--" in any of: 	C:\Program Files\Go\src\-- (from $GOROOT) 	C:\Users\cwolf\go\src\-- (from $GOPATH) 
```

I have no idea why these are being probed, because they do not exist at all and are not referenced anywhere.
The ones with hyphens do not even make sense of course.
The `integration` is also not a package but a `go:build` flag that I have at the top of a test file, which works as expected.

Further, when I set
```json
"go.languageServerExperimentalFeatures": {
    "diagnostics": true
},
```
all modules inside the workspace folder are marked as red because the error above is shown inside the mod files, and the notification still persists.

```
[Info  - 9:37:06 AM] 2023/01/26 09:37:05 go env for C:\Users\cwolf\Desktop
(root C:\Users\cwolf\Desktop)
(go version go version go1.19.5 windows/amd64)
(valid build configuration = false)
(build flags: [integration])
GOROOT=C:\Program Files\Go
GOINSECURE=
GOPATH=C:\Users\cwolf\go
GOPROXY=https://proxy.golang.org,direct
GOCACHE=C:\Users\cwolf\AppData\Local\go-build
GOPRIVATE=redacted
GO111MODULE=
GOFLAGS=
GOMODCACHE=C:\Users\cwolf\go\pkg\mod
GOSUMDB=sum.golang.org
GONOSUMDB=redacted
GOMOD=NUL
GOWORK=
GONOPROXY=redacted


[Error - 9:37:06 AM] 2023/01/26 09:37:05 initial workspace load failed: packages.Load error: err: exit status 1: stderr: cannot find package "integration" in any of:
	C:\Program Files\Go\src\integration (from $GOROOT)
	C:\Users\cwolf\go\src\integration (from $GOPATH)
cannot find package "-e" in any of:
	C:\Program Files\Go\src\-e (from $GOROOT)
	C:\Users\cwolf\go\src\-e (from $GOPATH)
cannot find package "-f" in any of:
	C:\Program Files\Go\src\-f (from $GOROOT)
	C:\Users\cwolf\go\src\-f (from $GOPATH)
cannot find package "{{context.ReleaseTags}}" in any of:
	C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT)
	C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH)
cannot find package "--" in any of:
	C:\Program Files\Go\src\-- (from $GOROOT)
	C:\Users\cwolf\go\src\-- (from $GOPATH)


[Error - 9:37:06 AM] 2023/01/26 09:37:05 go/packages.Load golang/vscode-go#1: err: exit status 1: stderr: cannot find package "integration" in any of:
	C:\Program Files\Go\src\integration (from $GOROOT)
	C:\Users\cwolf\go\src\integration (from $GOPATH)
cannot find package "-e" in any of:
	C:\Program Files\Go\src\-e (from $GOROOT)
	C:\Users\cwolf\go\src\-e (from $GOPATH)
cannot find package "-f" in any of:
	C:\Program Files\Go\src\-f (from $GOROOT)
	C:\Users\cwolf\go\src\-f (from $GOPATH)
cannot find package "{{context.ReleaseTags}}" in any of:
	C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT)
	C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH)
cannot find package "--" in any of:
	C:\Program Files\Go\src\-- (from $GOROOT)
	C:\Users\cwolf\go\src\-- (from $GOPATH)

	snapshot=0
	directory=file:///C:/Users/cwolf/Desktop
	query=[./ builtin]
	packages=0

[Info  - 9:37:07 AM] 2023/01/26 09:37:07 go env for C:\dev\devTools
(root C:\dev\devTools)
(go version go version go1.19.5 windows/amd64)
(valid build configuration = true)
(build flags: [integration])
GOPROXY=https://proxy.golang.org,direct
GOROOT=C:\Program Files\Go
GOSUMDB=sum.golang.org
GOFLAGS=
GOPRIVATE=redacted
GOMOD=NUL
GONOPROXY=redacted
GONOSUMDB=redacted
GOPATH=C:\Users\cwolf\go
GOWORK=C:\dev\devTools\go.work
GOCACHE=C:\Users\cwolf\AppData\Local\go-build
GOINSECURE=
GO111MODULE=
GOMODCACHE=C:\Users\cwolf\go\pkg\mod
```

The  `gopls (server)` `OUTPUT` shows:
```
[Error - 9:37:07 AM] 2023/01/26 09:37:07 go/packages.Load golang/vscode-go#2: err: exit status 1: stderr: cannot find package "integration" in any of:
	C:\Program Files\Go\src\integration (from $GOROOT)
	C:\Users\cwolf\go\src\integration (from $GOPATH)
cannot find package "-e" in any of:
	C:\Program Files\Go\src\-e (from $GOROOT)
	C:\Users\cwolf\go\src\-e (from $GOPATH)
cannot find package "-f" in any of:
	C:\Program Files\Go\src\-f (from $GOROOT)
	C:\Users\cwolf\go\src\-f (from $GOPATH)
cannot find package "{{context.ReleaseTags}}" in any of:
	C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT)
	C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH)
cannot find package "--" in any of:
	C:\Program Files\Go\src\-- (from $GOROOT)
	C:\Users\cwolf\go\src\-- (from $GOPATH)

	snapshot=0
	directory=file:///C:/dev/devTools
	query=[builtin redacted/... redacted/... redacted/...]
	packages=0

[Error - 9:37:07 AM] 2023/01/26 09:37:07 initial workspace load failed: packages.Load error: err: exit status 1: stderr: cannot find package "integration" in any of:
	C:\Program Files\Go\src\integration (from $GOROOT)
	C:\Users\cwolf\go\src\integration (from $GOPATH)
cannot find package "-e" in any of:
	C:\Program Files\Go\src\-e (from $GOROOT)
	C:\Users\cwolf\go\src\-e (from $GOPATH)
cannot find package "-f" in any of:
	C:\Program Files\Go\src\-f (from $GOROOT)
	C:\Users\cwolf\go\src\-f (from $GOPATH)
cannot find package "{{context.ReleaseTags}}" in any of:
	C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT)
	C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH)
cannot find package "--" in any of:
	C:\Program Files\Go\src\-- (from $GOROOT)
	C:\Users\cwolf\go\src\-- (from $GOPATH)


[Error - 9:37:07 AM] 2023/01/26 09:37:07 workspace packages: diagnosing file:///C:/dev/devTools/redacted/go.mod: packages.Load error: err: exit status 1: stderr: cannot find package "integration" in any of:
	C:\Program Files\Go\src\integration (from $GOROOT)
	C:\Users\cwolf\go\src\integration (from $GOPATH)
cannot find package "-e" in any of:
	C:\Program Files\Go\src\-e (from $GOROOT)
	C:\Users\cwolf\go\src\-e (from $GOPATH)
cannot find package "-f" in any of:
	C:\Program Files\Go\src\-f (from $GOROOT)
	C:\Users\cwolf\go\src\-f (from $GOPATH)
cannot find package "{{context.ReleaseTags}}" in any of:
	C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT)
	C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH)
cannot find package "--" in any of:
	C:\Program Files\Go\src\-- (from $GOROOT)
	C:\Users\cwolf\go\src\-- (from $GOPATH)


[Error - 9:37:07 AM] 2023/01/26 09:37:07 workspace packages: diagnosing file:///C:/dev/devTools/redactedr/go.mod: packages.Load error: err: exit status 1: stderr: cannot find package "integration" in any of:
	C:\Program Files\Go\src\integration (from $GOROOT)
	C:\Users\cwolf\go\src\integration (from $GOPATH)
cannot find package "-e" in any of:
	C:\Program Files\Go\src\-e (from $GOROOT)
	C:\Users\cwolf\go\src\-e (from $GOPATH)
cannot find package "-f" in any of:
	C:\Program Files\Go\src\-f (from $GOROOT)
	C:\Users\cwolf\go\src\-f (from $GOPATH)
cannot find package "{{context.ReleaseTags}}" in any of:
	C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT)
	C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH)
cannot find package "--" in any of:
	C:\Program Files\Go\src\-- (from $GOROOT)
	C:\Users\cwolf\go\src\-- (from $GOPATH)


[Error - 9:37:07 AM] 2023/01/26 09:37:07 workspace packages: diagnosing file:///C:/dev/devTools/redacted/go.mod: packages.Load error: err: exit status 1: stderr: cannot find package "integration" in any of:
	C:\Program Files\Go\src\integration (from $GOROOT)
	C:\Users\cwolf\go\src\integration (from $GOPATH)
cannot find package "-e" in any of:
	C:\Program Files\Go\src\-e (from $GOROOT)
	C:\Users\cwolf\go\src\-e (from $GOPATH)
cannot find package "-f" in any of:
	C:\Program Files\Go\src\-f (from $GOROOT)
	C:\Users\cwolf\go\src\-f (from $GOPATH)
cannot find package "{{context.ReleaseTags}}" in any of:
	C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT)
	C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH)
cannot find package "--" in any of:
	C:\Program Files\Go\src\-- (from $GOROOT)
	C:\Users\cwolf\go\src\-- (from $GOPATH)


[Error - 9:37:07 AM] 2023/01/26 09:37:07 errors loading workspace: packages.Load error: err: exit status 1: stderr: cannot find package "integration" in any of:
	C:\Program Files\Go\src\integration (from $GOROOT)
	C:\Users\cwolf\go\src\integration (from $GOPATH)
cannot find package "-e" in any of:
	C:\Program Files\Go\src\-e (from $GOROOT)
	C:\Users\cwolf\go\src\-e (from $GOPATH)
cannot find package "-f" in any of:
	C:\Program Files\Go\src\-f (from $GOROOT)
	C:\Users\cwolf\go\src\-f (from $GOPATH)
cannot find package "{{context.ReleaseTags}}" in any of:
	C:\Program Files\Go\src\{{context.ReleaseTags}} (from $GOROOT)
	C:\Users\cwolf\go\src\{{context.ReleaseTags}} (from $GOPATH)
cannot find package "--" in any of:
	C:\Program Files\Go\src\-- (from $GOROOT)
	C:\Users\cwolf\go\src\-- (from $GOPATH)

	snapshot=0
	directory=file:///C:/dev/devTools
```

Either way, everything builds and runs as expected despite these issues.

#### A clear and concise description of what you expected to happen.

That no non-existent packages/modules are tried to be loaded.

### Steps to reproduce the behavior:
1. Open VS Code
2. The loading notification in the status bar appears and after a short time shows the error notification.
3. Open the `gopls (server)` `OUTPUT`.
4. Its error output as dumped above is shown.