-
Notifications
You must be signed in to change notification settings - Fork 271
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
optimize error in the project #379
Comments
Hi ~ I'd like to work on this. |
Looking forward to your code |
There are |
TccFenceError 这种常量error,用 errors.New 来定义,比较的时候用 errors.Is 方法来比较,这样能解答你的疑惑吗 |
可以参考下这个规范:https://github.com/luky116/uber_go_guide_cn#%E9%94%99%E8%AF%AF%E7%B1%BB%E5%9E%8B |
OK, I see. Thx~ |
嗯嗯,建议是把error定义在需要用的文件,这样方便看代码 |
Well, the suggestion is to define the error in the file that needs to be used, so that it is convenient to read the code |
@luky116 cailao, 像这种
需要上下文的error,就没办法仅使用errors.New和fmt.Errorf了呀,还是得自定义一下,这种error期待改成什么样呢 |
用这个库重构一下吧 pkg/errors
这个 repo 好像没人维护了,可能需要讨论一下是否继续依赖,目前我们项目是依赖了的 |
What would you like to be added:
If you want to define an error variable, use errors.New, if it is a temporary error of return, use fmt.Errorf
如果定一个error变量,使用 errors.New 方法,如果是return一个临时error,使用fmt.Errorf
Why is this needed:
The text was updated successfully, but these errors were encountered: