Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use net.JoinHostPort to join host and port #715

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/go-canal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package main
import (
"flag"
"fmt"
"net"
"os"
"os/signal"
"strconv"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -38,7 +40,7 @@ func main() {
flag.Parse()

cfg := canal.NewDefaultConfig()
cfg.Addr = fmt.Sprintf("%s:%d", *host, *port)
cfg.Addr = net.JoinHostPort(*host, strconv.Itoa(*port))
cfg.User = *user
cfg.Password = *password
cfg.Flavor = *flavor
Expand Down
3 changes: 2 additions & 1 deletion replication/binlogsyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net"
"os"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -866,7 +867,7 @@ func (b *BinlogSyncer) LastConnectionID() uint32 {
func (b *BinlogSyncer) newConnection() (*client.Conn, error) {
var addr string
if b.cfg.Port != 0 {
addr = fmt.Sprintf("%s:%d", b.cfg.Host, b.cfg.Port)
addr = net.JoinHostPort(b.cfg.Host, strconv.Itoa(int(b.cfg.Port)))
} else {
addr = b.cfg.Host
}
Expand Down