Skip to content

Commit 28b6cd1

Browse files
authored
refactor: modify the form of variable declarations (#822)
1 parent 31e8e58 commit 28b6cd1

File tree

4 files changed

+47
-38
lines changed

4 files changed

+47
-38
lines changed

cmd/go-binlogparser/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import (
77
"github.com/go-mysql-org/go-mysql/replication"
88
)
99

10-
var name = flag.String("name", "", "binlog file name")
11-
var offset = flag.Int64("offset", 0, "parse start offset")
10+
var (
11+
name = flag.String("name", "", "binlog file name")
12+
offset = flag.Int64("offset", 0, "parse start offset")
13+
)
1214

1315
func main() {
1416
flag.Parse()

cmd/go-canal/main.go

+17-15
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,28 @@ import (
1515
"github.com/go-mysql-org/go-mysql/mysql"
1616
)
1717

18-
var host = flag.String("host", "127.0.0.1", "MySQL host")
19-
var port = flag.Int("port", 3306, "MySQL port")
20-
var user = flag.String("user", "root", "MySQL user, must have replication privilege")
21-
var password = flag.String("password", "", "MySQL password")
18+
var (
19+
host = flag.String("host", "127.0.0.1", "MySQL host")
20+
port = flag.Int("port", 3306, "MySQL port")
21+
user = flag.String("user", "root", "MySQL user, must have replication privilege")
22+
password = flag.String("password", "", "MySQL password")
2223

23-
var flavor = flag.String("flavor", "mysql", "Flavor: mysql or mariadb")
24+
flavor = flag.String("flavor", "mysql", "Flavor: mysql or mariadb")
2425

25-
var serverID = flag.Int("server-id", 101, "Unique Server ID")
26-
var mysqldump = flag.String("mysqldump", "mysqldump", "mysqldump execution path")
26+
serverID = flag.Int("server-id", 101, "Unique Server ID")
27+
mysqldump = flag.String("mysqldump", "mysqldump", "mysqldump execution path")
2728

28-
var dbs = flag.String("dbs", "test", "dump databases, separated by comma")
29-
var tables = flag.String("tables", "", "dump tables, separated by comma, will overwrite dbs")
30-
var tableDB = flag.String("table_db", "test", "database for dump tables")
31-
var ignoreTables = flag.String("ignore_tables", "", "ignore tables, must be database.table format, separated by comma")
29+
dbs = flag.String("dbs", "test", "dump databases, separated by comma")
30+
tables = flag.String("tables", "", "dump tables, separated by comma, will overwrite dbs")
31+
tableDB = flag.String("table_db", "test", "database for dump tables")
32+
ignoreTables = flag.String("ignore_tables", "", "ignore tables, must be database.table format, separated by comma")
3233

33-
var startName = flag.String("bin_name", "", "start sync from binlog name")
34-
var startPos = flag.Uint("bin_pos", 0, "start sync from binlog position of")
34+
startName = flag.String("bin_name", "", "start sync from binlog name")
35+
startPos = flag.Uint("bin_pos", 0, "start sync from binlog position of")
3536

36-
var heartbeatPeriod = flag.Duration("heartbeat", 60*time.Second, "master heartbeat period")
37-
var readTimeout = flag.Duration("read_timeout", 90*time.Second, "connection read timeout")
37+
heartbeatPeriod = flag.Duration("heartbeat", 60*time.Second, "master heartbeat period")
38+
readTimeout = flag.Duration("read_timeout", 90*time.Second, "connection read timeout")
39+
)
3840

3941
func main() {
4042
flag.Parse()

cmd/go-mysqlbinlog/main.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ import (
1515
"github.com/go-mysql-org/go-mysql/replication"
1616
)
1717

18-
var host = flag.String("host", "127.0.0.1", "MySQL host")
19-
var port = flag.Int("port", 3306, "MySQL port")
20-
var user = flag.String("user", "root", "MySQL user, must have replication privilege")
21-
var password = flag.String("password", "", "MySQL password")
18+
var (
19+
host = flag.String("host", "127.0.0.1", "MySQL host")
20+
port = flag.Int("port", 3306, "MySQL port")
21+
user = flag.String("user", "root", "MySQL user, must have replication privilege")
22+
password = flag.String("password", "", "MySQL password")
2223

23-
var flavor = flag.String("flavor", "mysql", "Flavor: mysql or mariadb")
24+
flavor = flag.String("flavor", "mysql", "Flavor: mysql or mariadb")
2425

25-
var file = flag.String("file", "", "Binlog filename")
26-
var pos = flag.Int("pos", 4, "Binlog position")
27-
var gtid = flag.String("gtid", "", "Binlog GTID set that this slave has executed")
26+
file = flag.String("file", "", "Binlog filename")
27+
pos = flag.Int("pos", 4, "Binlog position")
28+
gtid = flag.String("gtid", "", "Binlog GTID set that this slave has executed")
2829

29-
var semiSync = flag.Bool("semisync", false, "Support semi sync")
30-
var backupPath = flag.String("backup_path", "", "backup path to store binlog files")
30+
semiSync = flag.Bool("semisync", false, "Support semi sync")
31+
backupPath = flag.String("backup_path", "", "backup path to store binlog files")
3132

32-
var rawMode = flag.Bool("raw", false, "Use raw mode")
33+
rawMode = flag.Bool("raw", false, "Use raw mode")
34+
)
3335

3436
func main() {
3537
flag.Parse()

cmd/go-mysqldump/main.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@ import (
66
"os"
77
"strings"
88

9-
"github.com/go-mysql-org/go-mysql/dump"
109
"github.com/pingcap/errors"
10+
11+
"github.com/go-mysql-org/go-mysql/dump"
1112
)
1213

13-
var addr = flag.String("addr", "127.0.0.1:3306", "MySQL addr")
14-
var user = flag.String("user", "root", "MySQL user")
15-
var password = flag.String("password", "", "MySQL password")
16-
var execution = flag.String("exec", "mysqldump", "mysqldump execution path")
17-
var output = flag.String("o", "", "dump output, empty for stdout")
14+
var (
15+
addr = flag.String("addr", "127.0.0.1:3306", "MySQL addr")
16+
user = flag.String("user", "root", "MySQL user")
17+
password = flag.String("password", "", "MySQL password")
18+
execution = flag.String("exec", "mysqldump", "mysqldump execution path")
19+
output = flag.String("o", "", "dump output, empty for stdout")
1820

19-
var dbs = flag.String("dbs", "", "dump databases, separated by comma")
20-
var tables = flag.String("tables", "", "dump tables, separated by comma, will overwrite dbs")
21-
var tableDB = flag.String("table_db", "", "database for dump tables")
22-
var ignoreTables = flag.String("ignore_tables", "", "ignore tables, must be database.table format, separated by comma")
21+
dbs = flag.String("dbs", "", "dump databases, separated by comma")
22+
tables = flag.String("tables", "", "dump tables, separated by comma, will overwrite dbs")
23+
tableDB = flag.String("table_db", "", "database for dump tables")
24+
ignoreTables = flag.String("ignore_tables", "", "ignore tables, must be database.table format, separated by comma")
25+
)
2326

2427
func main() {
2528
flag.Parse()

0 commit comments

Comments
 (0)