File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -17,15 +17,17 @@ func CanonicalNetworkAddress(address string, defaultPort int) string {
17
17
if ip != nil {
18
18
// If the input address is a bare IP address, then convert it to a proper listen address
19
19
// using the canonical IP with default port and wrap IPv6 addresses in square brackets.
20
- address = net .JoinHostPort (ip .String (), fmt .Sprintf ("%d" , defaultPort ))
21
- } else {
22
- // Otherwise assume this is either a host name or a partial address (e.g `[::]`) without
23
- // a port number, so append the default port.
24
- address = fmt .Sprintf ("%s:%d" , address , defaultPort )
20
+ return net .JoinHostPort (ip .String (), fmt .Sprintf ("%d" , defaultPort ))
25
21
}
26
- } else if port == "" && address [len (address )- 1 ] == ':' {
22
+
23
+ // Otherwise assume this is either a host name or a partial address (e.g `[::]`) without
24
+ // a port number, so append the default port.
25
+ return fmt .Sprintf ("%s:%d" , address , defaultPort )
26
+ }
27
+
28
+ if port == "" && address [len (address )- 1 ] == ':' {
27
29
// An address that ends with a trailing colon will be parsed as having an empty port.
28
- address = net .JoinHostPort (host , fmt .Sprintf ("%d" , defaultPort ))
30
+ return net .JoinHostPort (host , fmt .Sprintf ("%d" , defaultPort ))
29
31
}
30
32
31
33
return address
You can’t perform that action at this time.
0 commit comments