errors.Is 检查整条包装链

版本新特性 / Go 1.13

err := readConfig()

// *** before: ***
if err == ErrNotFound {
    // never true: err is wrapped by fmt.Errorf
}

// *** in version 1.13: ***
if errors.Is(err, ErrNotFound) {
    fmt.Println("config not found")
}