use net.JoinHostPort instead of fmt.Sprintf (#2791)

This commit is contained in:
fatedier authored and GitHub committed 2022-02-09 15:19:35 +08:00
1 parent b2311e55e7
commit 6194273615
17 files changed
+61 -49

No files matched your search

+2 -1
View File
@@ -19,6 +19,7 @@ import (
"crypto/rand"
"encoding/hex"
"fmt"
"net"
"strconv"
"strings"
)
@@ -52,7 +53,7 @@ func CanonicalAddr(host string, port int) (addr string) {
if port == 80 || port == 443 {
addr = host
} else {
addr = fmt.Sprintf("%s:%d", host, port)
addr = net.JoinHostPort(host, strconv.Itoa(port))
}
return
}