hostsToIPStrings returns a slice of all unique IP addresses in the values of the given map.
(hosts map[dnsname.FQDN][]netip.Addr)
| 708 | // hostsToIPStrings returns a slice of all unique IP addresses in the values |
| 709 | // of the given map. |
| 710 | func hostsToIPStrings(hosts map[dnsname.FQDN][]netip.Addr) []string { |
| 711 | seen := make(map[netip.Addr]struct{}) |
| 712 | var result []string |
| 713 | for _, inner := range hosts { |
| 714 | for _, elem := range inner { |
| 715 | if _, exists := seen[elem]; !exists { |
| 716 | seen[elem] = struct{}{} |
| 717 | result = append(result, elem.String()) |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | return result |
| 722 | } |
| 723 | |
| 724 | // the following are taken from sloghuman: |
| 725 |
no test coverage detected