Skip to content

Commit 1a13a0e

Browse files
committed
Go: Log discovered Go modules in case workspace files can't be read/parsed
1 parent 52b273a commit 1a13a0e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

go/extractor/project/project.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

0 commit comments

Comments
 (0)