Skip to content

Commit

Permalink
Use net.JoinHostPort instead of raw string concatenation
Browse files Browse the repository at this point in the history
When adding a port to an IPv6 address, it must be wrapped with [...].
  • Loading branch information
PapaCharlie committed Feb 6, 2024
1 parent d93f41b commit 4bdd752
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion staticdnshostprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (shp *StaticHostProvider) Next() (server string, retryStart bool) {
slog.Warn("Could not resolve ZK host", "host", next.host, "err", err)
server = next.String()
} else {
server = addrs[rand.Intn(len(addrs))] + ":" + next.port
server = net.JoinHostPort(addrs[rand.Intn(len(addrs))], next.port)
}

shp.nextServer = (shp.nextServer + 1) % len(shp.servers)
Expand Down

0 comments on commit 4bdd752

Please sign in to comment.