cmd/showimp: support ignoring directories.
This commit is contained in:
parent
9e1aed257b
commit
b6b33e00c8
|
@ -67,6 +67,10 @@ func init() {
|
|||
}
|
||||
|
||||
func walkFile(path string, info os.FileInfo, err error) error {
|
||||
if ignores[path] {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
|
||||
if !sourceRegexp.MatchString(path) {
|
||||
return nil
|
||||
}
|
||||
|
@ -97,10 +101,24 @@ func walkFile(path string, info os.FileInfo, err error) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
var ignores = map[string]bool{}
|
||||
|
||||
func main() {
|
||||
var ignoreLine string
|
||||
var noVendor bool
|
||||
flag.StringVar(&ignoreLine, "i", "", "comma-separated list of directories to ignore")
|
||||
flag.BoolVar(&noVendor, "nv", false, "ignore the vendor directory")
|
||||
flag.BoolVar(&debug, "v", false, "log debugging information")
|
||||
flag.Parse()
|
||||
|
||||
if noVendor {
|
||||
ignores["vendor"] = true
|
||||
}
|
||||
|
||||
for _, word := range strings.Split(ignoreLine, ",") {
|
||||
ignores[strings.TrimSpace(word)] = true
|
||||
}
|
||||
|
||||
err := filepath.Walk(".", walkFile)
|
||||
die.If(err)
|
||||
|
||||
|
|
Loading…
Reference in New Issue