@@ -129,7 +129,7 @@ var filesToRemove []string = []string{}
129129
130130// Try to initialize a go.mod file for projects that do not already have one.
131131func 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 )
133133
134134 modInit := toolchain .InitModule (path )
135135
@@ -217,9 +217,13 @@ func discoverWorkspace(workFilePath string) GoWorkspace {
217217 if err != nil {
218218 // We couldn't read the `go.work` file for some reason; let's try to find `go.mod` files ourselves
219219 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+
220224 return GoWorkspace {
221225 BaseDir : baseDir ,
222- Modules : LoadGoModules (findGoModFiles ( baseDir ) ),
226+ Modules : LoadGoModules (goModFilePaths ),
223227 DepMode : GoGetWithModules ,
224228 ModMode : getModMode (GoGetWithModules , baseDir ),
225229 }
@@ -230,9 +234,13 @@ func discoverWorkspace(workFilePath string) GoWorkspace {
230234 if err != nil {
231235 // The `go.work` file couldn't be parsed for some reason; let's try to find `go.mod` files ourselves
232236 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+
233241 return GoWorkspace {
234242 BaseDir : baseDir ,
235- Modules : LoadGoModules (findGoModFiles ( baseDir ) ),
243+ Modules : LoadGoModules (goModFilePaths ),
236244 DepMode : GoGetWithModules ,
237245 ModMode : getModMode (GoGetWithModules , baseDir ),
238246 }
@@ -471,8 +479,10 @@ func getBuildRoots(emitDiagnostics bool) (goWorkspaces []GoWorkspace, totalModul
471479
472480// Finds Go workspaces in the current working directory.
473481func 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+ )
476486 if len (bazelPaths ) > 0 {
477487 // currently not supported
478488 if emitDiagnostics {
0 commit comments