@@ -91,10 +91,12 @@ func (p *PathList) FilterOutHiddenFiles() {
91
91
p .FilterOutPrefix ("." )
92
92
}
93
93
94
- func (p * PathList ) filter (filter func (* Path ) bool ) {
94
+ // Filter will remove all the elements of the list that do not match
95
+ // the specified acceptor function
96
+ func (p * PathList ) Filter (acceptorFunc func (* Path ) bool ) {
95
97
res := (* p )[:0 ]
96
98
for _ , path := range * p {
97
- if filter (path ) {
99
+ if acceptorFunc (path ) {
98
100
res = append (res , path )
99
101
}
100
102
}
@@ -106,31 +108,31 @@ func (p *PathList) FilterOutPrefix(prefixes ...string) {
106
108
filterFunction := func (path * Path ) bool {
107
109
return ! path .HasPrefix (prefixes ... )
108
110
}
109
- p .filter (filterFunction )
111
+ p .Filter (filterFunction )
110
112
}
111
113
112
114
// FilterPrefix remove all entries not having one of the specified prefixes
113
115
func (p * PathList ) FilterPrefix (prefixes ... string ) {
114
116
filterFunction := func (path * Path ) bool {
115
117
return path .HasPrefix (prefixes ... )
116
118
}
117
- p .filter (filterFunction )
119
+ p .Filter (filterFunction )
118
120
}
119
121
120
122
// FilterOutSuffix remove all entries having one of the specified suffixes
121
123
func (p * PathList ) FilterOutSuffix (suffixies ... string ) {
122
124
filterFunction := func (path * Path ) bool {
123
125
return ! path .HasSuffix (suffixies ... )
124
126
}
125
- p .filter (filterFunction )
127
+ p .Filter (filterFunction )
126
128
}
127
129
128
130
// FilterSuffix remove all entries not having one of the specified suffixes
129
131
func (p * PathList ) FilterSuffix (suffixies ... string ) {
130
132
filterFunction := func (path * Path ) bool {
131
133
return path .HasSuffix (suffixies ... )
132
134
}
133
- p .filter (filterFunction )
135
+ p .Filter (filterFunction )
134
136
}
135
137
136
138
// Add adds a Path to the PathList
0 commit comments