我在这里关注这个例子:
https://www.socketloop.com/tutorials/golang-smarter-error-handling-with-strings-contains-function
if !strings.Contains(err.Error(), "timed out") {
fmt.Printf("resulting error not a timeout: %s", err)
}
但是,如果我在我的代码中这样做,我会得到这个
err.Error 未定义(类型 interface {} 是没有方法的接口)
我想知道我在这里做错了什么,我应该如何检查确切的错误(在我的情况下,我想从错误“切片边界超出范围”中恢复)
最好的,
狐的传说
相关分类