您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

golang判断错误类型的方法

2024/3/28 4:48:34发布15次查看
error类型判断的方法:
go中返回的error类型究竟是什么呢?看源码发现error类型是一个非常简单的接口类型,具体如下
// the error built-in interface type is the conventional interface for// representing an error condition, with the nil value representing no error.type error interface { error() string}
error 有了一个签名为 error() string 的方法。所有实现该接口的类型都可以当作一个错误类型。error() 方法给出了错误的描述。
fmt.println 在打印错误时,会在内部调用 error() string 方法来得到该错误的描述。
更多golang知识请关注golang教程栏目。
以上就是golang判断错误类型的方法的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product