summaryrefslogtreecommitdiff
path: root/spew/bypass.go
diff options
context:
space:
mode:
authorDave Collins <[email protected]>2015-11-05 15:09:06 -0600
committerDave Collins <[email protected]>2015-11-05 15:13:17 -0600
commit5215b55f46b2b919f50a1df0eaa5886afe4e3b3d (patch)
treed451f6974f200663792b1942acbcaf5b00f920ec /spew/bypass.go
parent2df174808ee097f90d259e432cc04442cf60be21 (diff)
Add logic to deal with reflect pkg changes on tip.
This commit adds logic to gracefully the internal reflect.Value flag bit changes as of golang commit adf9b30e5594 while maintaining support all the back to Go 1.0. It accomplishes this by adding code to the init time inspection to detect the change and set the flag positions accordingly. While here, also removes a TODO comment since it was already done previously.
Diffstat (limited to 'spew/bypass.go')
-rw-r--r--spew/bypass.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/spew/bypass.go b/spew/bypass.go
index a8d27a3..565bf58 100644
--- a/spew/bypass.go
+++ b/spew/bypass.go
@@ -91,6 +91,21 @@ func init() {
flagKindShift = 0
flagRO = 1 << 5
flagIndir = 1 << 6
+
+ // Commit adf9b30e5594 modified the flags to separate the
+ // flagRO flag into two bits which specifies whether or not the
+ // field is embedded. This causes flagIndir to move over a bit
+ // and means that flagRO is the combination of either of the
+ // original flagRO bit and the new bit.
+ //
+ // This code detects the change by extracting what used to be
+ // the indirect bit to ensure it's set. When it's not, the flag
+ // order has been changed to the newer format, so the flags are
+ // updated accordingly.
+ if upfv&flagIndir == 0 {
+ flagRO = 3 << 5
+ flagIndir = 1 << 7
+ }
}
}