Skip to content

Commit 51eb487

Browse files
committed
Go: Handle filepath.Rel failure
1 parent c96735e commit 51eb487

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

go/extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,15 @@ func extract(workspace project.GoWorkspace) {
495495
extractorArgs = append(extractorArgs, workspace.ModMode.ArgsForGoVersion(toolchain.GetEnvGoSemVer())...)
496496
}
497497
for _, module := range workspace.Modules {
498-
relModPath, _ := filepath.Rel(workspace.BaseDir, filepath.Dir(module.Path))
499-
extractorArgs = append(extractorArgs, relModPath)
498+
relModPath, relErr := filepath.Rel(workspace.BaseDir, filepath.Dir(module.Path))
499+
500+
if relErr != nil {
501+
log.Printf(
502+
"Unable to make module path %s relative to workspace base dir %s: %s\n",
503+
filepath.Dir(module.Path), workspace.BaseDir, relErr.Error())
504+
} else {
505+
extractorArgs = append(extractorArgs, relModPath)
506+
}
500507
}
501508

502509
log.Printf("Running extractor command '%s %v' from directory '%s'.\n", extractor, extractorArgs, workspace.BaseDir)

0 commit comments

Comments
 (0)