-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/internal/cache: support workspace vendoring
Support workspace vendoring by simply removing logic in gopls for deriving the `-mod` flag. If we don't need to set `-mod=mod`, let the go command decide what to do. We don't need to worry about explicitly setting `-mod=readonly`, since this has been the default since Go 1.16. For golang/go#63375 Change-Id: I1adbe20cef5b9e3edcb7ac2445c4d5ae63f3a3a9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/560466 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
- Loading branch information
Showing
5 changed files
with
64 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import ( | |
"golang.org/x/tools/gopls/internal/util/bug" | ||
"golang.org/x/tools/gopls/internal/util/goversion" | ||
"golang.org/x/tools/internal/gocommand" | ||
"golang.org/x/tools/internal/testenv" | ||
|
||
. "golang.org/x/tools/gopls/internal/test/integration" | ||
) | ||
|
@@ -248,6 +249,32 @@ func TestAutomaticWorkspaceModule_Interdependent(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestWorkspaceVendoring(t *testing.T) { | ||
testenv.NeedsGo1Point(t, 22) | ||
WithOptions( | ||
ProxyFiles(workspaceModuleProxy), | ||
).Run(t, multiModule, func(t *testing.T, env *Env) { | ||
env.RunGoCommand("work", "init") | ||
env.RunGoCommand("work", "use", "moda/a") | ||
env.AfterChange() | ||
env.OpenFile("moda/a/a.go") | ||
env.RunGoCommand("work", "vendor") | ||
|
||
// Make an on-disk go.mod change to force a workspace reinitialization. | ||
// This will be fixed in a follow-up CL. | ||
env.OpenFile("moda/a/go.mod") | ||
env.EditBuffer("moda/a/go.mod", protocol.TextEdit{NewText: "// arbitrary\n"}) | ||
env.SaveBuffer("moda/a/go.mod") | ||
|
||
env.AfterChange() | ||
loc := env.GoToDefinition(env.RegexpSearch("moda/a/a.go", "b.(Hello)")) | ||
const want = "vendor/b.com/b/b.go" | ||
if got := env.Sandbox.Workdir.URIToPath(loc.URI); got != want { | ||
t.Errorf("Definition: got location %q, want %q", got, want) | ||
} | ||
}) | ||
} | ||
|
||
func TestModuleWithExclude(t *testing.T) { | ||
const proxy = ` | ||
-- [email protected]/go.mod -- | ||
|