removeItems drops entries matching ANY incoming item, by case-insensitive substring or by stem equality. Returns whether the list shrank.
(list *[]string, matchers []string)
| 286 | // removeItems drops entries matching ANY incoming item, by case-insensitive |
| 287 | // substring or by stem equality. Returns whether the list shrank. |
| 288 | func removeItems(list *[]string, matchers []string) bool { |
| 289 | if len(matchers) == 0 { |
| 290 | return false |
| 291 | } |
| 292 | kept := make([]string, 0, len(*list)) |
| 293 | for _, existing := range *list { |
| 294 | if entryMatchesAny(existing, matchers) { |
| 295 | continue |
| 296 | } |
| 297 | kept = append(kept, existing) |
| 298 | } |
| 299 | if len(kept) == len(*list) { |
| 300 | return false |
| 301 | } |
| 302 | *list = kept |
| 303 | return true |
| 304 | } |
| 305 | |
| 306 | func entryMatchesAny(entry string, matchers []string) bool { |
| 307 | le := strings.ToLower(entry) |
no test coverage detected