Skip to content

Fix issues reported by golangci-lint #121

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

Merged
merged 2 commits into from
Jan 22, 2024
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
11 changes: 7 additions & 4 deletions generate_perror/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func scanErrCodeFile(fileName string, nameToNum map[string]int) {
r := regexp.MustCompile(`^\s+(\w+)*\s+=\s+(\d+)$`)
for s.Scan() {
m := r.FindStringSubmatch(s.Text())
if m != nil && len(m) == 3 && m[1] != "" && m[2] != "" {
if len(m) == 3 && m[1] != "" && m[2] != "" {
i, err := strconv.Atoi(m[2])
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -134,7 +134,7 @@ func main() {
r := regexp.MustCompile(`^MySQL error code MY-0*(\d+) \((\w+)\)`)
for s.Scan() {
m := r.FindStringSubmatch(s.Text())
if m != nil && len(m) == 3 && m[1] != "" && m[2] != "" {
if len(m) == 3 && m[1] != "" && m[2] != "" {
c, err := strconv.Atoi(m[1])
if err != nil {
log.Fatal(err)
Expand All @@ -145,7 +145,10 @@ func main() {
checkNewErr(m[2], i, NameToNum)
}
}
cmd.Wait()
err = cmd.Wait()
if err != nil {
log.Fatal(err)
}
}
if maxError >= 1000 {
fmt.Printf("\r")
Expand All @@ -170,7 +173,7 @@ func main() {
sort.Slice(codes, func(i, j int) bool {
return codes[i].Code < codes[j].Code || codes[i].Code == codes[j].Code && codes[i].Name < codes[j].Name
})
for i, _ := range codes {
for i := range codes {
_, err = w.WriteString("\t\"" + codes[i].Name + `": ` + strconv.Itoa(codes[i].Code) + ",\n")
if err != nil {
log.Fatal(err)
Expand Down
10 changes: 8 additions & 2 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ func (t *tester) preProcess() {

func (t *tester) postProcess() {
if !reserveSchema {
t.mdb.Exec(fmt.Sprintf("drop database `%s`", strings.ReplaceAll(t.name, "/", "__")))
_, err := t.mdb.Exec(fmt.Sprintf("drop database `%s`", strings.ReplaceAll(t.name, "/", "__")))
if err != nil {
log.Errorf("failed to drop database: %s", err.Error())
}
}
for _, v := range t.conn {
v.conn.Close()
Expand Down Expand Up @@ -918,13 +921,16 @@ func (t *tester) executeStmt(query string) error {
}

if t.enableInfo {
t.curr.conn.Raw(func(driverConn any) error {
err = t.curr.conn.Raw(func(driverConn any) error {
rowsAffected := driverConn.(*mysql.MysqlConn).RowsAffected()
lastMessage := driverConn.(*mysql.MysqlConn).LastMessage()
t.buf.WriteString(fmt.Sprintf("affected rows: %d\n", rowsAffected))
t.buf.WriteString(fmt.Sprintf("info: %s\n", lastMessage))
return nil
})
if err != nil {
log.Errorf("failed to get info: %s", err.Error())
}
}

if t.enableWarning {
Expand Down