@@ -129,7 +129,7 @@ var filesToRemove []string = []string{}
129
129
130
130
// Try to initialize a go.mod file for projects that do not already have one.
131
131
func InitGoModForLegacyProject (path string ) {
132
- log .Printf ("Project appears to be a legacy Go project, attempting to initialize go.mod in %s \n " , path )
132
+ log .Printf ("The code in %s seems to be missing a go.mod file. Attempting to initialize one... \n " , path )
133
133
134
134
modInit := toolchain .InitModule (path )
135
135
@@ -217,9 +217,13 @@ func discoverWorkspace(workFilePath string) GoWorkspace {
217
217
if err != nil {
218
218
// We couldn't read the `go.work` file for some reason; let's try to find `go.mod` files ourselves
219
219
log .Printf ("Unable to read %s, falling back to finding `go.mod` files manually:\n %s\n " , workFilePath , err .Error ())
220
+
221
+ goModFilePaths := findGoModFiles (baseDir )
222
+ log .Printf ("Discovered the following Go modules in %s:\n %s\n " , baseDir , strings .Join (goModFilePaths , "\n " ))
223
+
220
224
return GoWorkspace {
221
225
BaseDir : baseDir ,
222
- Modules : LoadGoModules (findGoModFiles ( baseDir ) ),
226
+ Modules : LoadGoModules (goModFilePaths ),
223
227
DepMode : GoGetWithModules ,
224
228
ModMode : getModMode (GoGetWithModules , baseDir ),
225
229
}
@@ -230,9 +234,13 @@ func discoverWorkspace(workFilePath string) GoWorkspace {
230
234
if err != nil {
231
235
// The `go.work` file couldn't be parsed for some reason; let's try to find `go.mod` files ourselves
232
236
log .Printf ("Unable to parse %s, falling back to finding `go.mod` files manually:\n %s\n " , workFilePath , err .Error ())
237
+
238
+ goModFilePaths := findGoModFiles (baseDir )
239
+ log .Printf ("Discovered the following Go modules in %s:\n %s\n " , baseDir , strings .Join (goModFilePaths , "\n " ))
240
+
233
241
return GoWorkspace {
234
242
BaseDir : baseDir ,
235
- Modules : LoadGoModules (findGoModFiles ( baseDir ) ),
243
+ Modules : LoadGoModules (goModFilePaths ),
236
244
DepMode : GoGetWithModules ,
237
245
ModMode : getModMode (GoGetWithModules , baseDir ),
238
246
}
@@ -471,8 +479,10 @@ func getBuildRoots(emitDiagnostics bool) (goWorkspaces []GoWorkspace, totalModul
471
479
472
480
// Finds Go workspaces in the current working directory.
473
481
func GetWorkspaceInfo (emitDiagnostics bool ) []GoWorkspace {
474
- bazelPaths := util .FindAllFilesWithName ("." , "BUILD" , "vendor" )
475
- bazelPaths = append (bazelPaths , util .FindAllFilesWithName ("." , "BUILD.bazel" , "vendor" )... )
482
+ bazelPaths := slices .Concat (
483
+ util .FindAllFilesWithName ("." , "BUILD" , "vendor" ),
484
+ util .FindAllFilesWithName ("." , "BUILD.bazel" , "vendor" ),
485
+ )
476
486
if len (bazelPaths ) > 0 {
477
487
// currently not supported
478
488
if emitDiagnostics {
0 commit comments