Skip to content

Commit

Permalink
refactor: dir ignore func
Browse files Browse the repository at this point in the history
  • Loading branch information
iseki0 committed Jun 15, 2022
1 parent 4b9e049 commit 1812468
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions inspector/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ import (

//go:embed auto_scan_ignore
var _dirIgnoreText string
var ignoredDirMap map[string]struct{}

var dirIgnored = func() func(name string) bool {
m := map[string]struct{}{}
for _, it := range strings.Split(_dirIgnoreText, "\n") {
s := strings.TrimSpace(it)
if strings.HasPrefix(s, "#") {
func init() {
for _, s := range strings.Split(_dirIgnoreText, "\n") {
s := strings.TrimSpace(s)
if s == "" || strings.HasPrefix(s, "#") {
continue
}
m[s] = struct{}{}
ignoredDirMap[s] = struct{}{}
}
return func(name string) bool {
if strings.HasPrefix(name, ".") {
return true
}
_, ok := m[name]
return ok
}

func dirIgnored(name string) bool {
if strings.HasPrefix(name, ".") {
return true
}
}()
_, ok := ignoredDirMap[name]
return ok
}

0 comments on commit 1812468

Please sign in to comment.