瀏覽代碼

lib/config: Use net.JoinHostPort instead of string manipulation (#8470)

Jakob Borg 3 年之前
父節點
當前提交
5977868165
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      lib/config/config.go

+ 1 - 1
lib/config/config.go

@@ -590,7 +590,7 @@ func filterURLSchemePrefix(addrs []string, prefix string) []string {
 // a random high port is returned.
 func getFreePort(host string, ports ...int) (int, error) {
 	for _, port := range ports {
-		c, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, port))
+		c, err := net.Listen("tcp", net.JoinHostPort(host, strconv.Itoa(port)))
 		if err == nil {
 			c.Close()
 			return port, nil