diff options
author | Felix Lange <fjl@twurst.com> | 2015-04-17 07:16:46 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-04-17 20:45:09 +0800 |
commit | cad64fb911e7029bef876f16e0956b3b0b4bb4d0 (patch) | |
tree | 89c0005bc28fe08cb54cab9c49800a21c2f1bf94 /rlp/encode.go | |
parent | 1e2c93aa2da453ef9548b9957b5ed453f60ce5ca (diff) | |
download | go-tangerine-cad64fb911e7029bef876f16e0956b3b0b4bb4d0.tar.gz go-tangerine-cad64fb911e7029bef876f16e0956b3b0b4bb4d0.tar.zst go-tangerine-cad64fb911e7029bef876f16e0956b3b0b4bb4d0.zip |
rlp: stricter rules for structs and pointers
The rules have changed as follows:
* When decoding into pointers, empty values no longer produce
a nil pointer. This can be overriden for struct fields using the
struct tag "nil".
* When decoding into structs, the input list must contain an element
for each field.
Diffstat (limited to 'rlp/encode.go')
-rw-r--r-- | rlp/encode.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/rlp/encode.go b/rlp/encode.go index 6cf6776d6..10ff0ae79 100644 --- a/rlp/encode.go +++ b/rlp/encode.go @@ -194,7 +194,7 @@ func (w *encbuf) Write(b []byte) (int, error) { func (w *encbuf) encode(val interface{}) error { rval := reflect.ValueOf(val) - ti, err := cachedTypeInfo(rval.Type()) + ti, err := cachedTypeInfo(rval.Type(), tags{}) if err != nil { return err } @@ -485,7 +485,7 @@ func writeInterface(val reflect.Value, w *encbuf) error { return nil } eval := val.Elem() - ti, err := cachedTypeInfo(eval.Type()) + ti, err := cachedTypeInfo(eval.Type(), tags{}) if err != nil { return err } @@ -493,7 +493,7 @@ func writeInterface(val reflect.Value, w *encbuf) error { } func makeSliceWriter(typ reflect.Type) (writer, error) { - etypeinfo, err := cachedTypeInfo1(typ.Elem()) + etypeinfo, err := cachedTypeInfo1(typ.Elem(), tags{}) if err != nil { return nil, err } @@ -530,7 +530,7 @@ func makeStructWriter(typ reflect.Type) (writer, error) { } func makePtrWriter(typ reflect.Type) (writer, error) { - etypeinfo, err := cachedTypeInfo1(typ.Elem()) + etypeinfo, err := cachedTypeInfo1(typ.Elem(), tags{}) if err != nil { return nil, err } |