Description
gopls version
golang.org/x/tools/gopls v0.8.1
compiled with go1.18 (google-golang)
What did you do?
We have a project that has a third-party go project as its git submodule.
my_project
+--- go.work
+--- their_project
+--- go.mod
+--- main.go
go.work has only ./their_project
in it.
I opened vscode from my_project
, so gopls sees my_project
as the workspace root.
What did you expect to see?
Working normally.
What did you see instead?
All go files in the their_project directory get errors with source go list
.
gopls log:
[Trace - 23:38:54.242 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///home/hakim/projects/my_project/their_project/cmd/tester/main.go",
"diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},
"severity":1,
"source":"go list",
"message":"error obtaining VCS status: main package is in repository
\"/home/hakim/projects/my_project/their_project\" but current directory is in repository
\"/home/hakim/projects/my_project\"\n\tUse -buildvcs=false to disable VCS stamping."}]}
I understand this is an error message from go
, and I can work around by disabling the buildvcs
flag.
However, what's puzzling is, if I run go list
from their_project
, it runs without an error.
$ go list ./triage-party/...
error obtaining VCS status: main package is in repository "/home/hakim/projects/my_project/their_project" but current directory is in repository "/home/hakim/projects/my_project"
Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: main package is in repository "/home/hakim/projects/my_project/their_project" but current directory is in repository "/home/hakim/projects/my_project"
Use -buildvcs=false to disable VCS stamping.
$ cd ./triage-party; go list ./...
go list ./...
github.com/they/their_project/cmd/server
...
I don't know what's right default behavior for the go command (this is probably a niche use case) cc @bcmills
but these confusing error messages make me think gopls
disable vcs build stamping by default when running go commands.
(why does gopls have to care about build stamping?)