package filter import ( "os" "path/filepath" "strings" ) type Filter struct { MaxSize int64 Extensions []string Ignores []string } func (f *Filter) ShouldSkipDir(name string) bool { if strings.HasPrefix(name, ".") { return true } for _, pattern := range f.Ignores { matched, _ := filepath.Match(pattern, name) if matched { return true } } return false } func (f *Filter) ShouldSkipFile(path, name string, info os.FileInfo) bool { if strings.HasPrefix(name, ".") { return true } for _, pattern := range f.Ignores { matched, _ := filepath.Match(pattern, name) if matched { return true } } ext := filepath.Ext(path) for _, bad := range f.Extensions { if strings.EqualFold(ext, bad) { return true } } if info.Size() > f.MaxSize { return true } return false } func IsSymlink(path string) bool { info, err := os.Lstat(path) if err != nil { return false } return info.Mode()&os.ModeSymlink != 0 }