10 // URLHostname will extract the Hostname without port from the URL value.
12 // Copy of Go 1.8's net/url#URL.Hostname functionality.
13 func URLHostname(url *url.URL) string {
14 return stripPort(url.Host)
18 // stripPort is copy of Go 1.8 url#URL.Hostname functionality.
19 // https://golang.org/src/net/url/url.go
20 func stripPort(hostport string) string {
21 colon := strings.IndexByte(hostport, ':')
25 if i := strings.IndexByte(hostport, ']'); i != -1 {
26 return strings.TrimPrefix(hostport[:i], "[")
28 return hostport[:colon]