aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go')
-rw-r--r--Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go31
1 files changed, 17 insertions, 14 deletions
diff --git a/Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go b/Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go
index 5783145b7..a0ff95e27 100644
--- a/Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go
+++ b/Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go
@@ -181,25 +181,28 @@ func (d *dumpState) dumpSlice(v reflect.Value) {
// Try to use existing uint8 slices and fall back to converting
// and copying if that fails.
case vt.Kind() == reflect.Uint8:
- // We need an addressable interface to convert the type back
- // into a byte slice. However, the reflect package won't give
- // us an interface on certain things like unexported struct
- // fields in order to enforce visibility rules. We use unsafe
- // to bypass these restrictions since this package does not
+ // We need an addressable interface to convert the type
+ // to a byte slice. However, the reflect package won't
+ // give us an interface on certain things like
+ // unexported struct fields in order to enforce
+ // visibility rules. We use unsafe, when available, to
+ // bypass these restrictions since this package does not
// mutate the values.
vs := v
if !vs.CanInterface() || !vs.CanAddr() {
vs = unsafeReflectValue(vs)
}
- vs = vs.Slice(0, numEntries)
-
- // Use the existing uint8 slice if it can be type
- // asserted.
- iface := vs.Interface()
- if slice, ok := iface.([]uint8); ok {
- buf = slice
- doHexDump = true
- break
+ if !UnsafeDisabled {
+ vs = vs.Slice(0, numEntries)
+
+ // Use the existing uint8 slice if it can be
+ // type asserted.
+ iface := vs.Interface()
+ if slice, ok := iface.([]uint8); ok {
+ buf = slice
+ doHexDump = true
+ break
+ }
}
// The underlying data needs to be converted if it can't