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

enabled gosimple in golangci #665

Merged
merged 2 commits into from
Jan 19, 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
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ linters:
- unconvert
- whitespace
- govet
- gosimple
- ineffassign
# ToDo:
#- gosimple
#- gocritic
#- golint
linters-settings:
Expand Down
2 changes: 1 addition & 1 deletion canal/canal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion canal/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion dump/dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion dump/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion replication/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down