Go: Handle filepath.Rel failure

This commit is contained in:
Michael B. Gale
2024-02-01 11:45:47 +00:00
parent c96735e17a
commit 51eb487022

View File

@@ -495,8 +495,15 @@ func extract(workspace project.GoWorkspace) {
extractorArgs = append(extractorArgs, workspace.ModMode.ArgsForGoVersion(toolchain.GetEnvGoSemVer())...)
}
for _, module := range workspace.Modules {
relModPath, _ := filepath.Rel(workspace.BaseDir, filepath.Dir(module.Path))
extractorArgs = append(extractorArgs, relModPath)
relModPath, relErr := filepath.Rel(workspace.BaseDir, filepath.Dir(module.Path))
if relErr != nil {
log.Printf(
"Unable to make module path %s relative to workspace base dir %s: %s\n",
filepath.Dir(module.Path), workspace.BaseDir, relErr.Error())
} else {
extractorArgs = append(extractorArgs, relModPath)
}
}
log.Printf("Running extractor command '%s %v' from directory '%s'.\n", extractor, extractorArgs, workspace.BaseDir)