mirror of
https://github.com/golang/go
synced 2024-11-26 08:27:56 -07:00
errors/wrap: do not call Elem() twice
Change-Id: I2fe6037c45a0dfe25f946a92ff97b5e3fbd69bc0
GitHub-Last-Rev: 644d479a27
GitHub-Pull-Request: golang/go#44851
Reviewed-on: https://go-review.googlesource.com/c/go/+/299629
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
parent
289d34a465
commit
fedb494878
@ -83,10 +83,10 @@ func As(err error, target interface{}) bool {
|
|||||||
if typ.Kind() != reflectlite.Ptr || val.IsNil() {
|
if typ.Kind() != reflectlite.Ptr || val.IsNil() {
|
||||||
panic("errors: target must be a non-nil pointer")
|
panic("errors: target must be a non-nil pointer")
|
||||||
}
|
}
|
||||||
if e := typ.Elem(); e.Kind() != reflectlite.Interface && !e.Implements(errorType) {
|
targetType := typ.Elem()
|
||||||
|
if targetType.Kind() != reflectlite.Interface && !targetType.Implements(errorType) {
|
||||||
panic("errors: *target must be interface or implement error")
|
panic("errors: *target must be interface or implement error")
|
||||||
}
|
}
|
||||||
targetType := typ.Elem()
|
|
||||||
for err != nil {
|
for err != nil {
|
||||||
if reflectlite.TypeOf(err).AssignableTo(targetType) {
|
if reflectlite.TypeOf(err).AssignableTo(targetType) {
|
||||||
val.Elem().Set(reflectlite.ValueOf(err))
|
val.Elem().Set(reflectlite.ValueOf(err))
|
||||||
|
Loading…
Reference in New Issue
Block a user