File tree 1 file changed +45
-0
lines changed
gopls/internal/test/integration/workspace 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -818,6 +818,51 @@ use (
818
818
})
819
819
}
820
820
821
+ func TestInnerGoWork (t * testing.T ) {
822
+ // This test checks that gopls honors a go.work file defined
823
+ // inside a go module (golang/go#63917).
824
+ const workspace = `
825
+ -- go.mod --
826
+ module a.com
827
+
828
+ require b.com v1.2.3
829
+ -- a/go.work --
830
+ go 1.18
831
+
832
+ use (
833
+ ..
834
+ ../b
835
+ )
836
+ -- a/a.go --
837
+ package a
838
+
839
+ import "b.com/b"
840
+
841
+ var _ = b.B
842
+ -- b/go.mod --
843
+ module b.com/b
844
+
845
+ -- b/b.go --
846
+ package b
847
+
848
+ const B = 0
849
+ `
850
+ WithOptions (
851
+ // This doesn't work if we open the outer module. I'm not sure it should,
852
+ // since the go.work file does not apply to the entire module, just a
853
+ // subdirectory.
854
+ WorkspaceFolders ("a" ),
855
+ ).Run (t , workspace , func (t * testing.T , env * Env ) {
856
+ env .OpenFile ("a/a.go" )
857
+ loc := env .GoToDefinition (env .RegexpSearch ("a/a.go" , "b.(B)" ))
858
+ got := env .Sandbox .Workdir .URIToPath (loc .URI )
859
+ want := "b/b.go"
860
+ if got != want {
861
+ t .Errorf ("Definition(b.B): got %q, want %q" , got , want )
862
+ }
863
+ })
864
+ }
865
+
821
866
func TestNonWorkspaceFileCreation (t * testing.T ) {
822
867
const files = `
823
868
-- work/go.mod --
You can’t perform that action at this time.
0 commit comments