mirror of
https://github.com/gomods/athens
synced 2026-02-03 13:20:30 +00:00
41 lines
732 B
Go
41 lines
732 B
Go
package module
|
|
|
|
import (
|
|
"strings"
|
|
|
|
ignore "github.com/sabhiram/go-gitignore"
|
|
)
|
|
|
|
type multiIgnoreParser struct {
|
|
parsers []ignore.IgnoreParser
|
|
}
|
|
|
|
// Returns map of patterns for more performant searches
|
|
func newMultiIgnoreParser(parsers ...ignore.IgnoreParser) ignore.IgnoreParser {
|
|
parser := multiIgnoreParser{}
|
|
|
|
for _, p := range parsers {
|
|
if p != nil {
|
|
parser.parsers = append(parser.parsers, p)
|
|
}
|
|
}
|
|
|
|
return parser
|
|
}
|
|
|
|
func (p multiIgnoreParser) MatchesPath(f string) bool {
|
|
for _, parser := range p.parsers {
|
|
if parser.MatchesPath(f) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
type dsStoreIgnoreParser struct{}
|
|
|
|
func (p dsStoreIgnoreParser) MatchesPath(f string) bool {
|
|
return strings.Contains(f, "/.DS_Store")
|
|
}
|