diff options
author | Felix Lange <fjl@twurst.com> | 2017-03-07 19:37:53 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2017-03-07 19:45:12 +0800 |
commit | eee96a5bb7439ccee583d23e53be018fe7c35cfb (patch) | |
tree | 93e027d5c6456eb87b8d2e1e13977251bc500b2f /rlp/typecache.go | |
parent | 667cd518ceada7084698c8ea11d966db9f9e674a (diff) | |
download | dexon-eee96a5bb7439ccee583d23e53be018fe7c35cfb.tar dexon-eee96a5bb7439ccee583d23e53be018fe7c35cfb.tar.gz dexon-eee96a5bb7439ccee583d23e53be018fe7c35cfb.tar.bz2 dexon-eee96a5bb7439ccee583d23e53be018fe7c35cfb.tar.lz dexon-eee96a5bb7439ccee583d23e53be018fe7c35cfb.tar.xz dexon-eee96a5bb7439ccee583d23e53be018fe7c35cfb.tar.zst dexon-eee96a5bb7439ccee583d23e53be018fe7c35cfb.zip |
rlp: add support for "-" struct tag
Diffstat (limited to 'rlp/typecache.go')
-rw-r--r-- | rlp/typecache.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/rlp/typecache.go b/rlp/typecache.go index a2f217c66..3df799e1e 100644 --- a/rlp/typecache.go +++ b/rlp/typecache.go @@ -37,11 +37,12 @@ type typeinfo struct { type tags struct { // rlp:"nil" controls whether empty input results in a nil pointer. nilOK bool - // rlp:"tail" controls whether this field swallows additional list // elements. It can only be set for the last field, which must be // of slice type. tail bool + // rlp:"-" ignores fields. + ignored bool } type typekey struct { @@ -101,6 +102,9 @@ func structFields(typ reflect.Type) (fields []field, err error) { if err != nil { return nil, err } + if tags.ignored { + continue + } info, err := cachedTypeInfo1(f.Type, tags) if err != nil { return nil, err @@ -117,6 +121,8 @@ func parseStructTag(typ reflect.Type, fi int) (tags, error) { for _, t := range strings.Split(f.Tag.Get("rlp"), ",") { switch t = strings.TrimSpace(t); t { case "": + case "-": + ts.ignored = true case "nil": ts.nilOK = true case "tail": |