File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -283,6 +283,43 @@ func discoverWorkspaces(emitDiagnostics bool) []GoWorkspace {
283
283
for i , workFilePath := range goWorkFiles {
284
284
results [i ] = discoverWorkspace (workFilePath )
285
285
}
286
+
287
+ // Add all stray `go.mod` files (i.e. those not referenced by `go.work` files)
288
+ // as separate workspaces.
289
+ goModFiles := findGoModFiles ("." )
290
+
291
+ for _ , goModFile := range goModFiles {
292
+ // Check to see whether we already have this module file under an existing workspace.
293
+ found := false
294
+ for _ , workspace := range results {
295
+ if workspace .Modules == nil {
296
+ break
297
+ }
298
+
299
+ for _ , module := range workspace .Modules {
300
+ if module .Path == goModFile {
301
+ found = true
302
+ break
303
+ }
304
+ }
305
+
306
+ if found {
307
+ break
308
+ }
309
+ }
310
+
311
+ // If not, add it to the array.
312
+ if ! found {
313
+ log .Printf ("Module %s is not referenced by any go.work file; adding it separately.\n " , goModFile )
314
+ results = append (results , GoWorkspace {
315
+ BaseDir : filepath .Dir (goModFile ),
316
+ Modules : loadGoModules ([]string {goModFile }),
317
+ DepMode : GoGetWithModules ,
318
+ ModMode : getModMode (GoGetWithModules , filepath .Dir (goModFile )),
319
+ })
320
+ }
321
+ }
322
+
286
323
return results
287
324
}
288
325
}
You can’t perform that action at this time.
0 commit comments