removeAddrs removes any address in exclude from addrs (case-insensitive).
(addrs []string, exclude []string)
| 352 | |
| 353 | // removeAddrs removes any address in exclude from addrs (case-insensitive). |
| 354 | func removeAddrs(addrs []string, exclude []string) []string { |
| 355 | if len(exclude) == 0 { |
| 356 | return addrs |
| 357 | } |
| 358 | set := make(map[string]struct{}, len(exclude)) |
| 359 | for _, e := range exclude { |
| 360 | set[strings.ToLower(e)] = struct{}{} |
| 361 | } |
| 362 | out := make([]string, 0, len(addrs)) |
| 363 | for _, a := range addrs { |
| 364 | if _, ok := set[strings.ToLower(a)]; !ok { |
| 365 | out = append(out, a) |
| 366 | } |
| 367 | } |
| 368 | return out |
| 369 | } |
| 370 | |
| 371 | // dedupe removes duplicate addresses preserving order (case-insensitive). |
| 372 | func dedupe(addrs []string) []string { |