aboutsummaryrefslogtreecommitdiff
path: root/src/internal/reflectlite/value.go
diff options
context:
space:
mode:
authorOri Rawlings <orirawlings@gmail.com>2020-05-28 22:41:38 -0500
committerIan Lance Taylor <iant@golang.org>2020-10-07 00:15:09 +0000
commitc19725016df2600a204c9f8447bfcb7dcbdb128a (patch)
treedbfdbb1ecfd63c7f4180cb9779abd419fbd1ec8c /src/internal/reflectlite/value.go
parentf8e554021b7de4bf1150f64d047091b429c92b39 (diff)
downloadgo-c19725016df2600a204c9f8447bfcb7dcbdb128a.tar.xz
internal/reflectlite: include Kind in ValueError message
The implementation has been ported from reflect, but to avoid introducing a dependency on strconv, Kind.String() falls back to "invalid" if the Kind is unknown rather than "kind" + strconv.Itoa(int(k)) Fixes #39286 Change-Id: I82277242a6c41d0146dabd9d20339fe72d562500 Reviewed-on: https://go-review.googlesource.com/c/go/+/235522 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'src/internal/reflectlite/value.go')
-rw-r--r--src/internal/reflectlite/value.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/internal/reflectlite/value.go b/src/internal/reflectlite/value.go
index 85beea606c..0365eeeabf 100644
--- a/src/internal/reflectlite/value.go
+++ b/src/internal/reflectlite/value.go
@@ -160,7 +160,10 @@ type ValueError struct {
}
func (e *ValueError) Error() string {
- return "reflect: call of " + e.Method + " on zero Value"
+ if e.Kind == 0 {
+ return "reflect: call of " + e.Method + " on zero Value"
+ }
+ return "reflect: call of " + e.Method + " on " + e.Kind.String() + " Value"
}
// methodName returns the name of the calling method,