mirror of
https://github.com/golang/go
synced 2024-09-05 16:04:50 +00: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() {
|
||||
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")
|
||||
}
|
||||
targetType := typ.Elem()
|
||||
for err != nil {
|
||||
if reflectlite.TypeOf(err).AssignableTo(targetType) {
|
||||
val.Elem().Set(reflectlite.ValueOf(err))
|
||||
|
|
Loading…
Reference in a new issue