const UnsafeDisabled … const ptrSize … type flag … var flagRO … var flagAddr … const flagKindMask … var okFlags … var flagValOffset … // flagField returns a pointer to the flag field of a reflect.Value. func flagField(v *reflect.Value) *flag { … } // unsafeReflectValue converts the passed reflect.Value into a one that bypasses // the typical safety restrictions preventing access to unaddressable and // unexported data. It works by digging the raw pointer to the underlying // value out of the protected value and generating a new unprotected (unsafe) // reflect.Value to it. // // This allows us to check for implementations of the Stringer and error // interfaces to be used for pretty printing ordinarily unaddressable and // inaccessible values such as unexported struct fields. func unsafeReflectValue(v reflect.Value) reflect.Value { … } // Sanity checks against future reflect package changes // to the type or semantics of the Value.flag field. func init() { … }