diff --git a/.golangci.yml b/.golangci.yml index 94d42e4c1..67db52444 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,9 +16,9 @@ linters: - unconvert - whitespace - govet + - gosimple - ineffassign # ToDo: - #- gosimple #- gocritic #- golint linters-settings: 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 b0370780a..26a7570bb 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 }