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

Function getHostPortWithDefaults

options.go:549–561  ·  view source on GitHub ↗

getHostPortWithDefaults is a helper function that splits the url into a host and a port. If the host is missing, it defaults to localhost and if the port is missing, it defaults to 6379.

(u *url.URL)

Source from the content-addressed store, hash-verified

547// a host and a port. If the host is missing, it defaults to localhost
548// and if the port is missing, it defaults to 6379.
549func getHostPortWithDefaults(u *url.URL) (string, string) {
550 host, port, err := net.SplitHostPort(u.Host)
551 if err != nil {
552 host = u.Host
553 }
554 if host == "" {
555 host = "localhost"
556 }
557 if port == "" {
558 port = "6379"
559 }
560 return host, port
561}
562
563func setupUnixConn(u *url.URL) (*Options, error) {
564 o := &Options{

Callers 3

setupTCPConnFunction · 0.85
ParseClusterURLFunction · 0.85
setupFailoverConnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected