From c494c77c1c776a0aac68b4fb4bb10de24c43409b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:54:36 +0900 Subject: [PATCH] optimize(http): use net.JoinHostPort --- http.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/http.go b/http.go index ba5a26b..16b3265 100644 --- a/http.go +++ b/http.go @@ -8,7 +8,6 @@ import ( "errors" "net" "net/http" - "strings" "time" "github.com/FloatTech/ttl" @@ -61,12 +60,7 @@ var cli = http.Client{ } var tlsConn *tls.Conn for _, a := range addrs { - if strings.Contains(a, ":") { - a = "[" + a + "]:" + port - } else { - a += ":" + port - } - conn, err := httpdialer.DialContext(ctx, network, a) + conn, err := httpdialer.DialContext(ctx, network, net.JoinHostPort(a, port)) if err != nil { continue }