From 6dafd68873245a61e828442fa7270a8e521f2a8a Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Mon, 20 Jul 2015 11:21:24 -0700 Subject: [PATCH] Add comment on binary/reflect and nil-dogs --- binary/reflect.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/binary/reflect.go b/binary/reflect.go index 25cf730ce..a97025467 100644 --- a/binary/reflect.go +++ b/binary/reflect.go @@ -447,6 +447,9 @@ func writeReflectBinary(rv reflect.Value, rt reflect.Type, opts Options, w io.Wr rv, rt = rv.Elem(), rt.Elem() typeInfo = GetTypeInfo(rt) 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) return } @@ -845,6 +848,9 @@ func writeReflectJSON(rv reflect.Value, rt reflect.Type, w io.Writer, n *int64, rv, rt = rv.Elem(), rt.Elem() typeInfo = GetTypeInfo(rt) 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) return }