File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -72,14 +72,14 @@ Offset字段在调用Error的时候不会被打印,但是我们可以通过类
7272 return err
7373 }
7474
75- 需要注意的是,函数返回自定义错误时,返回值也应设置为error类型 ,而非自定义错误类型,也不应预声明自定义错误类型的变量 。例如:
75+ 需要注意的是,函数返回自定义错误时,返回值推荐设置为error类型 ,而非自定义错误类型,特别需要注意的是不应预声明自定义错误类型的变量 。例如:
7676
7777 func Decode() *SyntaxError { // 错误,将可能导致上层调用者err!=nil的判断永远为true。
7878 var err *SyntaxError // 预声明错误变量
7979 if 出错条件 {
8080 err = &SyntaxError{}
8181 }
82- return err // 错误,虽然err变量等于nil,但仍可能导致上层调用者err!=nil的判断为true
82+ return err // 错误,err永远等于非nil,导致上层调用者err!=nil的判断始终为true
8383 }
8484
8585原因见 http://golang.org/doc/faq#nil_error
Original file line number Diff line number Diff line change @@ -260,5 +260,5 @@ ControllerRegistor对外的接口函数有
260260
261261## links
262262 * [ 目录] ( < preface.md > )
263- * 上一章: [ 数据库设计 ] ( < 13.2 .md > )
264- * 下一节: [ controller设计] ( < 13.4 .md > )
263+ * 上一章: [ 项目规划 ] ( < 13.1 .md > )
264+ * 下一节: [ controller设计] ( < 13.3 .md > )
You can’t perform that action at this time.
0 commit comments