Skip to content

Commit fbd7946

Browse files
committed
Go: Fall back to ./... if there are no modules
Fixes issues for `dep` and `glide`
1 parent 0b8a917 commit fbd7946

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -494,15 +494,21 @@ func extract(workspace project.GoWorkspace) {
494494
if workspace.DepMode == project.GoGetWithModules {
495495
extractorArgs = append(extractorArgs, workspace.ModMode.ArgsForGoVersion(toolchain.GetEnvGoSemVer())...)
496496
}
497-
for _, module := range workspace.Modules {
498-
relModPath, relErr := filepath.Rel(workspace.BaseDir, filepath.Dir(module.Path))
499497

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)
498+
if len(workspace.Modules) == 0 {
499+
// There may be no modules if we are using e.g. Dep or Glide
500+
extractorArgs = append(extractorArgs, "./...")
501+
} else {
502+
for _, module := range workspace.Modules {
503+
relModPath, relErr := filepath.Rel(workspace.BaseDir, filepath.Dir(module.Path))
504+
505+
if relErr != nil {
506+
log.Printf(
507+
"Unable to make module path %s relative to workspace base dir %s: %s\n",
508+
filepath.Dir(module.Path), workspace.BaseDir, relErr.Error())
509+
} else {
510+
extractorArgs = append(extractorArgs, relModPath)
511+
}
506512
}
507513
}
508514

0 commit comments

Comments
 (0)