-
Notifications
You must be signed in to change notification settings - Fork 288
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
feat:add more linter in configuration file #686
Conversation
feat:add more linter
feat:change golangclilint version to 1.57.x to support more linter
feat:adjust lint conf and adjust the code to pass the check
@@ -144,7 +144,9 @@ func (m *mysqlTrigger) getColumnMetas(ctx context.Context, dbName string, table | |||
columnMeta.Autoincrement = strings.Contains(strings.ToLower(extra), "auto_increment") | |||
columnMetas = append(columnMetas, columnMeta) | |||
} | |||
|
|||
if err := rows.Err(); err != nil { | |||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -156,7 +156,7 @@ func isRegisterSuccess(response interface{}) bool { | |||
func isReportSuccess(response interface{}) error { | |||
if res, ok := response.(message.BranchReportResponse); ok { | |||
if res.ResultCode == message.ResultCodeFailed { | |||
return fmt.Errorf(res.Msg) | |||
return errors.New(res.Msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为啥改动?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为啥改动?
ci的go-linter加了一下errcheck,这里过不了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考这个,golang/lint#284
@@ -144,7 +144,9 @@ func (m *mysqlTrigger) getColumnMetas(ctx context.Context, dbName string, table | |||
columnMeta.Autoincrement = strings.Contains(strings.ToLower(extra), "auto_increment") | |||
columnMetas = append(columnMetas, columnMeta) | |||
} | |||
|
|||
if err := rows.Err(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果要加,应该加载 103 行之前,使用 rows 之前进行判断
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果要加,应该加载 103 行之前,使用 rows 之前进行判断
就是在之后加,Next的描述为,Next prepares the next result row for reading with the [Rows.Scan] method. It returns true on success, or false if there is no next result row or an error happened while preparing it. [Rows.Err] should be consulted to distinguish between the two cases.读取过程中出现error也会导致循环退出,所以需要把可能存在的error读出来,参考这个https://stackoverflow.com/questions/67434205/how-does-the-rows-err-of-database-sql-work
@@ -204,6 +206,8 @@ func (m *mysqlTrigger) getIndexes(ctx context.Context, dbName string, tableName | |||
result = append(result, index) | |||
|
|||
} | |||
|
|||
if err := rows.Err(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里放到 174 行之前是否更好
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
就是在之后加,Next的描述为,Next prepares the next result row for reading with the [Rows.Scan] method. It returns true on success, or false if there is no next result row or an error happened while preparing it. [Rows.Err] should be consulted to distinguish between the two cases.读取过程中出现error也会导致循环退出,所以需要把可能存在的error读出来,参考这个https://stackoverflow.com/questions/67434205/how-does-the-rows-err-of-database-sql-work
|
LGTM |
What this PR does:
add more linter in configuration file
Which issue(s) this PR fixes:
Fixes #
#479
Special notes for your reviewer:
Does this PR introduce a user-facing change?: