From 077eab1b24d779fdb35eef910ec263e1a8169895 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Thu, 22 Oct 2020 07:34:26 +0200 Subject: [PATCH] Chore: Use net.JoinHostPort (#28421) Signed-off-by: Arve Knudsen --- pkg/api/http_server.go | 2 +- pkg/services/ldap/ldap.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/api/http_server.go b/pkg/api/http_server.go index 623feb63dfc..b1076c0de0a 100644 --- a/pkg/api/http_server.go +++ b/pkg/api/http_server.go @@ -107,7 +107,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error { hs.applyRoutes() hs.httpSrv = &http.Server{ - Addr: fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort), + Addr: net.JoinHostPort(setting.HttpAddr, setting.HttpPort), Handler: hs.macaron, } switch setting.Protocol { diff --git a/pkg/services/ldap/ldap.go b/pkg/services/ldap/ldap.go index e799b00cead..3c89311954f 100644 --- a/pkg/services/ldap/ldap.go +++ b/pkg/services/ldap/ldap.go @@ -7,6 +7,8 @@ import ( "fmt" "io/ioutil" "math" + "net" + "strconv" "strings" "github.com/davecgh/go-spew/spew" @@ -110,7 +112,7 @@ func (server *Server) Dial() error { } } for _, host := range strings.Split(server.Config.Host, " ") { - address := fmt.Sprintf("%s:%d", host, server.Config.Port) + address := net.JoinHostPort(host, strconv.Itoa(server.Config.Port)) if server.Config.UseSSL { tlsCfg := &tls.Config{ InsecureSkipVerify: server.Config.SkipVerifySSL,