Overview
Package errors implements functions to manipulate errors.
errors包实现了处理错误的方法
Function
-
func As(err error, target interface{}) bool
-
As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true. Otherwise, it returns false.
-
-
func Is(err, target error) bool
-
Is reports whether any error in err's chain matches target.
-
-
-
即使text相同,每次调用返回一个新的错误
-
可以用 fmt.Errorf() 来达到返回错误的效果
-
-
-
如果err没有Unwrap方法, 返回 nil
-
推荐阅读 :一套优雅的 Go 错误问题解决方案