MCPcopy
hub / github.com/grpc/grpc-go / ParseDialTarget

Function ParseDialTarget

internal/transport/http_util.go:607–632  ·  view source on GitHub ↗

ParseDialTarget returns the network and address to pass to dialer.

(target string)

Source from the content-addressed store, hash-verified

605
606// ParseDialTarget returns the network and address to pass to dialer.
607func ParseDialTarget(target string) (string, string) {
608 net := "tcp"
609 m1 := strings.Index(target, ":")
610 m2 := strings.Index(target, ":/")
611 // handle unix:addr which will fail with url.Parse
612 if m1 >= 0 && m2 < 0 {
613 if n := target[0:m1]; n == "unix" {
614 return n, target[m1+1:]
615 }
616 }
617 if m2 >= 0 {
618 t, err := url.Parse(target)
619 if err != nil {
620 return net, target
621 }
622 scheme := t.Scheme
623 addr := t.Path
624 if scheme == "unix" {
625 if addr == "" {
626 addr = t.Host
627 }
628 return scheme, addr
629 }
630 }
631 return net, target
632}

Callers 3

skipProxyFunction · 0.92
TestParseDialTargetMethod · 0.85
dialFunction · 0.85

Calls 1

ParseMethod · 0.65

Tested by 1

TestParseDialTargetMethod · 0.68