Skip to content

Commit 20626b6

Browse files
dkorunicmjuraga
authored andcommitted
MINOR: go: Use net.JoinHostPort() instead of generic fmt.Sprintf()
1 parent 92ec833 commit 20626b6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

discovery/consul_service_discovery_instance.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package discovery
1818
import (
1919
"context"
2020
"fmt"
21+
"net"
22+
"strconv"
2123
"time"
2224

2325
"github.com/haproxytech/client-native/v4/configuration"
@@ -73,7 +75,7 @@ func (c *consulInstance) start() error {
7375
}
7476

7577
func (c *consulInstance) setAPIClient() error {
76-
address := fmt.Sprintf("%s:%d", *c.params.Address, *c.params.Port)
78+
address := net.JoinHostPort(*c.params.Address, strconv.FormatInt(*c.params.Port, 10))
7779
consulConfig := api.DefaultConfig()
7880
consulConfig.Address = address
7981
consulConfig.Token = c.params.Token

0 commit comments

Comments
 (0)