summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Collins <[email protected]>2013-01-20 17:37:24 -0600
committerDave Collins <[email protected]>2013-01-20 17:37:24 -0600
commit6024e0c79eec3c66cc3e1807fc6169800d3c53ea (patch)
tree77d1342161576637dfeda8dda720d62ebf1ec699
parent0cd00fd3ae2b6b5ff044ac9feb6d51f631a15c2e (diff)
Invoke String/Error methods on addressable vals.
If a type implements a Stringer or error interface with a pointer receiver and the value being formatted is addressable, the interface should be invoked even when the DisablePointerMethods option is set. DisablePointerMethods is only intended to prevent the potentially unsafe action of stepping around type-safety restriction to invoke a Stringer or error interface with a pointer to an unaddressable value.
-rw-r--r--spew/common.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/spew/common.go b/spew/common.go
index 945b0b0..6b8bfec 100644
--- a/spew/common.go
+++ b/spew/common.go
@@ -140,6 +140,9 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
}
viface = v.Addr().Interface()
} else {
+ if v.CanAddr() {
+ v = v.Addr()
+ }
viface = v.Interface()
}