From 0e0a68305381d7b62718a1ee1036e132f53b9a0c Mon Sep 17 00:00:00 2001 From: Reinier Schoof Date: Fri, 14 Jan 2022 16:36:46 +0100 Subject: [PATCH] enabled gosimple in golangci --- .golangci.yml | 2 +- canal/canal.go | 2 +- canal/dump.go | 2 +- dump/dumper.go | 2 +- dump/parser.go | 2 +- replication/event.go | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 997630c58..ec3651581 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,8 +16,8 @@ linters: - unconvert - whitespace - govet + - gosimple # ToDo: - #- gosimple #- ineffassign #- gocritic #- golint diff --git a/canal/canal.go b/canal/canal.go index 4fd19a2b0..a4a1ed55d 100644 --- a/canal/canal.go +++ b/canal/canal.go @@ -316,7 +316,7 @@ func (c *Canal) GetTable(db string, table string) (*schema.Table, error) { c.tableLock.RLock() lastTime, ok := c.errorTablesGetTime[key] c.tableLock.RUnlock() - if ok && time.Now().Sub(lastTime) < UnknownTableRetryPeriod { + if ok && time.Since(lastTime) < UnknownTableRetryPeriod { return nil, schema.ErrMissingTableMeta } } diff --git a/canal/dump.go b/canal/dump.go index 59af3a433..2267a37a8 100644 --- a/canal/dump.go +++ b/canal/dump.go @@ -186,7 +186,7 @@ func (c *Canal) dump() error { startPos = h.gset } log.Infof("dump MySQL and parse OK, use %0.2f seconds, start binlog replication at %s", - time.Now().Sub(start).Seconds(), startPos) + time.Since(start).Seconds(), startPos) return nil } diff --git a/dump/dumper.go b/dump/dumper.go index 038624885..dda9b8957 100644 --- a/dump/dumper.go +++ b/dump/dumper.go @@ -136,7 +136,7 @@ func (d *Dumper) AddTables(db string, tables ...string) { } func (d *Dumper) AddIgnoreTables(db string, tables ...string) { - t, _ := d.IgnoreTables[db] + t := d.IgnoreTables[db] t = append(t, tables...) d.IgnoreTables[db] = t } diff --git a/dump/parser.go b/dump/parser.go index d4694a2a5..2e9a18e0d 100644 --- a/dump/parser.go +++ b/dump/parser.go @@ -29,7 +29,7 @@ var valuesExp *regexp.Regexp var gtidExp *regexp.Regexp func init() { - binlogExp = regexp.MustCompile("^CHANGE MASTER TO MASTER_LOG_FILE='(.+)', MASTER_LOG_POS=(\\d+);") + binlogExp = regexp.MustCompile(`^CHANGE MASTER TO MASTER_LOG_FILE='(.+)', MASTER_LOG_POS=(\d+);`) useExp = regexp.MustCompile("^USE `(.+)`;") valuesExp = regexp.MustCompile("^INSERT INTO `(.+?)` VALUES \\((.+)\\);$") // The pattern will only match MySQL GTID, as you know SET GLOBAL gtid_slave_pos='0-1-4' is used for MariaDB. diff --git a/replication/event.go b/replication/event.go index 9111691d2..7792b3ac3 100644 --- a/replication/event.go +++ b/replication/event.go @@ -251,7 +251,7 @@ func (e *PreviousGTIDsEvent) Decode(data []byte) error { } previousGTIDSets = append(previousGTIDSets, fmt.Sprintf("%s:%s", uuid, strings.Join(intervals, ":"))) } - e.GTIDSets = fmt.Sprintf("%s", strings.Join(previousGTIDSets, ",")) + e.GTIDSets = strings.Join(previousGTIDSets, ",") return nil }