blob: 55969e909be60541ed403b5f9cb80a1aa828537f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package client
import (
"fmt"
"net/url"
)
func parseAddress(rawAddress string) (canonicalAddress string, err error) {
u, err := url.Parse(rawAddress)
if err != nil {
return "", err
}
// tcp:// addresses are a special case which `grpc.Dial` expects in a
// different format
if u.Scheme == "tcp" || u.Scheme == "tls" {
if u.Path != "" {
return "", fmt.Errorf("%s addresses should not have a path", u.Scheme)
}
return u.Host, nil
}
return u.String(), nil
}
|