Browse Source

Add comment on binary/reflect and nil-dogs

pull/118/head
Jae Kwon 9 years ago
parent
commit
6dafd68873
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      binary/reflect.go

+ 6
- 0
binary/reflect.go View File

@ -447,6 +447,9 @@ func writeReflectBinary(rv reflect.Value, rt reflect.Type, opts Options, w io.Wr
rv, rt = rv.Elem(), rt.Elem() rv, rt = rv.Elem(), rt.Elem()
typeInfo = GetTypeInfo(rt) typeInfo = GetTypeInfo(rt)
if !rv.IsValid() { if !rv.IsValid() {
// For better compatibility with other languages,
// as far as tendermint/binary is concerned,
// pointers to nil values are the same as nil.
WriteByte(0x00, w, n, err) WriteByte(0x00, w, n, err)
return return
} }
@ -845,6 +848,9 @@ func writeReflectJSON(rv reflect.Value, rt reflect.Type, w io.Writer, n *int64,
rv, rt = rv.Elem(), rt.Elem() rv, rt = rv.Elem(), rt.Elem()
typeInfo = GetTypeInfo(rt) typeInfo = GetTypeInfo(rt)
if !rv.IsValid() { if !rv.IsValid() {
// For better compatibility with other languages,
// as far as tendermint/binary is concerned,
// pointers to nil values are the same as nil.
WriteTo([]byte("null"), w, n, err) WriteTo([]byte("null"), w, n, err)
return return
} }


Loading…
Cancel
Save