-
Notifications
You must be signed in to change notification settings - Fork 328
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
refactor: remove func ErrWhenBuildListIdx #443
refactor: remove func ErrWhenBuildListIdx #443
Conversation
Codecov Report
@@ Coverage Diff @@
## master #443 +/- ##
==========================================
- Coverage 66.97% 66.46% -0.51%
==========================================
Files 34 34
Lines 5910 5892 -18
==========================================
- Hits 3958 3916 -42
- Misses 1606 1620 +14
- Partials 346 356 +10
|
db.go
Outdated
@@ -856,7 +856,7 @@ func (db *DB) buildOtherIdxes(r *Record) error { | |||
switch r.H.Meta.Ds { | |||
case DataStructureList: | |||
if err := db.buildListIdx(r); err != nil { | |||
return err | |||
return fmt.Errorf("when build listIdx err: %s", 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.
The string can be defined into a const string variable. That will make the code more elegant.
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.
The string can be defined into a const string variable. That will make the code more elegant.
OK : )
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.
The string can be defined into a const string variable. That will make the code more elegant.
I refactored code so that fmt.Errorf
was only called once and I didn't use const
to define this pattern string, because I think it would be more intuitive if only called once.
Thanks for this significant contribution, and that can be an excellent first issue. |
没有特殊的考虑,应该只是前后的开发者没有统一上🤣,可以将 err 都这么包装一下 |
好的 另外,我觉得在每个case都使用 var err error
switch EXPR {
case A:
err = doSomething1()
case B:
err = doSomething2()
case C:
err = doSomething3()
if err != nil {
break
}
err = doSomething4()
case D:
err = doSomething5()
}
if err != nil {
return fmt.Errorf("some wrap words %s", err)
}
return nil golang日志库zap中存在类似的写法 |
确实这是一种更优雅的方式 👍 |
c98ee41
to
060fdd3
Compare
已经按照这种方式更改了 |
我又增加了一些评论,麻烦看一下😁 |
7185b09
to
ec9bb6a
Compare
好嘞,已经按照意见进行了一些修改 |
都用这种风格的话, |
好滴没问题 |
注意到在 |
这次先把构建索引的处理逻辑处理吧,可以一步一步来 |
好滴 |
已经将 |
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.
LGTM! 感谢你的杰出贡献😁
This pr come from #403
Remove func:
ErrWhenBuildListIdx
Founded that
ErrWhenBuildListIdx
only has been called inbuildListIdx
, which only return anerror
. So I usefmt.Errorf
to wrap the returnederror
wherebuildListIdx
is called.Additionally,
Go 1.18
no longer haserrors.Wrap
, so I usefmt.Errorf
to finish this pr.This's my first pr in this repo, correct me if something wrong. : )