Skip to content

Commit 2fcc636

Browse files
committed
Support default god package 'main'
1 parent 9f209e1 commit 2fcc636

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ func analyze(args []string) int {
9191
log.Printf("FATAL - %v", err)
9292
return 3
9393
}
94+
cfg.God, err = data.NewSimplePatternList([]string{"main"}, "god")
95+
if err != nil {
96+
log.Printf("FATAL - %v", err)
97+
return 5
98+
}
9499
}
95100

96101
log.Printf("INFO - dependency tables for package(s): %s", docPkgs)

parse/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// looking for Go packages and analyzing them.
1313
func DirTree(root string) ([]*pkgs.Package, error) {
1414
parseCfg := &packages.Config{
15-
Logf: nil, // log.Printf (for debug), nil (for release)
15+
Logf: nil, // log.Printf (for debug) or nil (for release)
1616
Dir: root,
1717
Tests: true,
1818
Mode: packages.NeedName | packages.NeedImports | packages.NeedSyntax,

x/dirs/dirs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func readPatternFromFile(depFile, prefix, rootPkg string) (string, error) {
9999
if strings.HasPrefix(strings.ToLower(l), prefix) {
100100
pattern := l[len(prefix):]
101101
pattern = strings.TrimSpace(pattern)
102-
if strings.HasPrefix(rootPkg, pattern) {
102+
if strings.HasPrefix(pattern, rootPkg) {
103103
pattern = pattern[len(rootPkg):]
104104
if pattern != "" && pattern[0] == '/' {
105105
pattern = pattern[1:]

0 commit comments

Comments
 (0)