cmd/go,x/tools/gopls: confusing behavior of go mod when go.work is in play #60430
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.
Milestone
What version of Go are you using (
go version
)?What did you do?
with a go workspace https://github.com/frankli0324/workspace_demo (I committed the go.work file for demonstration purposes)
module_a can be compiled
now remove go.work, compilation fails with:
also note that
go install github.com/frankli0324/workspace_demo/module_a
succeeds, andgo install github.com/frankli0324/workspace_demo/module_b@remove-go-work
also succeeds.the
remove-go-work
branch doesn't have a go.work file and module_a doesn't require module_bWhat did you expect to see?/What did you see instead?
I expect either gopls to stop complaining about missing modules in go.mod and "you must go mod tidy" or go build/install fail to build the module if go.mod is incorrectly constructed (missing require)
Conclusion
From what I observe, I believe the essence of
go work
is forcing submodules to build as if there's anreplace $declared_module_name => ./$local_path
in each of the usedgo.mod
s:in persudo-code:
However, normally if module_a doesn't require module_b, if module_b is replaced anyway, go build still fails:
this is where I think is inconsistent and erroneous.
I'm aware that #52962 raised the issue already, but I believe it's not a duplicate. Also the issue seems wasted since no one is getting anywhere closer to an answer.
The text was updated successfully, but these errors were encountered: