bencode: Use default field name if it isn't given (but options are)

This commit is contained in:
Matt Joiner 2015-10-19 01:27:15 +11:00
parent 644ee0a244
commit ddf7cbbdac
1 changed files with 3 additions and 1 deletions

View File

@ -237,7 +237,9 @@ func encode_fields(t reflect.Type) []encode_field {
continue
}
name, opts := parse_tag(tv)
ef.tag = name
if name != "" {
ef.tag = name
}
ef.omit_empty = opts.contains("omitempty")
}
fs = append(fs, ef)