encodeEndpoint returns a string that uniquely identifies the unordered set of addresses within an endpoint.
(e Endpoint)
| 199 | // encodeEndpoint returns a string that uniquely identifies the unordered set of |
| 200 | // addresses within an endpoint. |
| 201 | func encodeEndpoint(e Endpoint) endpointMapKey { |
| 202 | addrs := make([]string, 0, len(e.Addresses)) |
| 203 | // base64 encoding the address strings restricts the characters present |
| 204 | // within the strings. This allows us to use a delimiter without the need of |
| 205 | // escape characters. |
| 206 | for _, addr := range e.Addresses { |
| 207 | addrs = append(addrs, base64.StdEncoding.EncodeToString([]byte(addr.Addr))) |
| 208 | } |
| 209 | sort.Strings(addrs) |
| 210 | // " " should not appear in base64 encoded strings. |
| 211 | return endpointMapKey(strings.Join(addrs, " ")) |
| 212 | } |
| 213 | |
| 214 | // Get returns the value for the address in the map, if present. |
| 215 | func (em *EndpointMap[T]) Get(e Endpoint) (value T, ok bool) { |
no test coverage detected