MCPcopy
hub / github.com/redis/go-redis / splitHostPort

Function splitHostPort

extra/redisotel-native/metrics.go:439–452  ·  view source on GitHub ↗

splitHostPort splits a host:port string into host and port This is a simplified version that handles the common cases

(addr string)

Source from the content-addressed store, hash-verified

437// splitHostPort splits a host:port string into host and port
438// This is a simplified version that handles the common cases
439func splitHostPort(addr string) (host, port string) {
440 // Handle Unix sockets
441 if strings.HasPrefix(addr, "/") || strings.HasPrefix(addr, "@") {
442 return addr, ""
443 }
444
445 host, port, err := net.SplitHostPort(addr)
446 if err != nil {
447 // If split fails, return the whole address as host
448 return addr, ""
449 }
450
451 return host, port
452}
453
454// parseAddr parses a Redis address into host and port
455func parseAddr(addr string) (host, port string) {

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected