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: misleading error message when having multiple workspace folders and using build tag #60776

Open
hyangah opened this issue Jun 14, 2023 · 1 comment
Assignees
Labels
gopls/metadata Issues related to metadata loading in gopls gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Jun 14, 2023

gopls version

v0.12.2 (or v0.12.1)

go env

go env
 go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hakim/Library/Caches/go-build"
GOENV="/Users/hakim/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/hakim/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/hakim/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/hakim/projects/tmp-misleading/mod1/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/5p/zn7ykc111kn3lm09h_47mz2w001py5/T/go-build89764978=/tmp/go-build -gno-record-gcc-switches -fno-common"
gopls stats
gopls stats 
Initializing workspace...     done (281.462653ms)
Gathering bug reports...      done (368.227003ms)
Querying memstats...          done (4.590305ms)
Querying workspace stats...   done (716.432µs)
Collecting directory info...  done (186.099µs)
{
  "BugReports": [],
  "CacheDir": "/Users/hakim/Library/Caches/gopls/309eafdc",
  "DirStats": {
    "Files": 4,
    "TestdataFiles": 0,
    "GoFiles": 2,
    "ModFiles": 1,
    "Dirs": 1
  },
  "GOARCH": "amd64",
  "GOOS": "darwin",
  "GOPLSCACHE": "",
  "GoVersion": "go1.20.3",
  "GoplsVersion": "v0.12.1",
  "InitialWorkspaceLoadDuration": "281.462653ms",
  "MemStats": {
    "HeapAlloc": 9656168,
    "HeapInUse": 15237120,
    "TotalAlloc": 36597232
  },
  "WorkspaceStats": {
    "Files": {
      "Total": 447,
      "Largest": 201909,
      "Errs": 0
    },
    "Views": [
      {
        "GoCommandVersion": "go1.20.3",
        "AllPackages": {
          "Packages": 48,
          "LargestPackage": 132,
          "CompiledGoFiles": 444,
          "Modules": 2
        },
        "WorkspacePackages": {
          "Packages": 1,
          "LargestPackage": 1,
          "CompiledGoFiles": 1,
          "Modules": 1
        },
        "Diagnostics": 0
      }
    ]
  }
}

What did you do?

git clone https://github.com/hyangah/tmp-misleading
cd tmp-misleading/mod1
code .

Then, from the VS Code window open with the setting, open buildtag.go which has //go:build tag.

What did you expect to see?

Usual build-tag related error message on the package line

What did you see instead?

"This file is within module ".", which is not included in your workspace.
To fix this problem, you can add a go.work file that uses this directory.
See the documentation for more information on setting up your workspace:
https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.go list"

Screenshot 2023-06-13 at 9 30 43 PM

@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 Jun 14, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jun 14, 2023
@findleyr
Copy link
Contributor

Thanks. We should improve this heuristic.

Milestoning for v0.12.4.

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.12.4 Jun 15, 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 self-assigned this Feb 6, 2024
@findleyr findleyr modified the milestones: gopls/v0.15.0, gopls/v0.16.0 Feb 16, 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. 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