Skip to content

Commit

Permalink
Fix issue with file ordering
Browse files Browse the repository at this point in the history
A bug exists in the logic that determines if `go.mod` exists: if a `*.go` file is returned by the filesystem before `go.mod`, we will not skip the
subtree as intended. To fix this, we always stat for `go.mod` if we find a `*.go` file, as a final check before considering the path to be
a subpackage.
  • Loading branch information
LandonTClipp committed Feb 15, 2024
1 parent d4e7f57 commit b915439
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,16 @@ func (c *Config) subPackages(
}
}

pathLog.Debug().Msg("subdirectory has a .go file, adding this path to packages config")
pathLog.Debug().Msg("subdirectory has a .go file")
goModExists, err := path.Parent().Join("go.mod").Exists()
if err != nil {
pathLog.Err(err).Msg("failed to determine if go.mod exists")
return err
}
if goModExists {
pathLog.Debug().Msg("found .go file, but go.mod exists. Skipping.")
return pathlib.ErrWalkSkipSubtree
}
subdirectoriesWithGoFiles = append(subdirectoriesWithGoFiles, path.Parent())
visitedDirs[path.Parent().String()] = nil
}
Expand Down

0 comments on commit b915439

Please sign in to comment.