}
// called when 'i' was consumed
-func (d *Decoder) parse_int(v reflect.Value) {
+func (d *Decoder) parseInt(v reflect.Value) {
start := d.offset - 1
d.readUntil('e')
if d.buf.Len() == 0 {
d.buf.Reset()
}
-func (d *Decoder) parse_string(v reflect.Value) {
+func (d *Decoder) parseString(v reflect.Value) {
start := d.offset - 1
// read the string length first
d.buf.Reset()
}
-func (d *Decoder) parse_dict(v reflect.Value) {
+func (d *Decoder) parseDict(v reflect.Value) {
switch v.Kind() {
case reflect.Map:
t := v.Type()
})
}
- var map_elem reflect.Value
+ var mapElem reflect.Value
// so, at this point 'd' byte was consumed, let's just read key/value
// pairs one by one
switch v.Kind() {
case reflect.Map:
elem_type := v.Type().Elem()
- if !map_elem.IsValid() {
- map_elem = reflect.New(elem_type).Elem()
+ if !mapElem.IsValid() {
+ mapElem = reflect.New(elem_type).Elem()
} else {
- map_elem.Set(reflect.Zero(elem_type))
+ mapElem.Set(reflect.Zero(elem_type))
}
- valuev = map_elem
+ valuev = mapElem
case reflect.Struct:
var f reflect.StructField
var ok bool
continue
}
- tag_name, _ := parse_tag(tag)
+ tag_name, _ := parseTag(tag)
if tag_name == d.key {
ok = true
break
}
}
-func (d *Decoder) parse_list(v reflect.Value) {
+func (d *Decoder) parseList(v reflect.Value) {
switch v.Kind() {
case reflect.Array, reflect.Slice:
default:
case 'e':
return false
case 'd':
- d.parse_dict(v)
+ d.parseDict(v)
case 'l':
- d.parse_list(v)
+ d.parseList(v)
case 'i':
- d.parse_int(v)
+ d.parseInt(v)
default:
if b >= '0' && b <= '9' {
// string
// append first digit of the length to the buffer
d.buf.WriteByte(b)
- d.parse_string(v)
+ d.parseString(v)
break
}
"strings"
)
-type tag_options string
+type tagOptions string
-func parse_tag(tag string) (string, tag_options) {
+func parseTag(tag string) (string, tagOptions) {
if idx := strings.Index(tag, ","); idx != -1 {
- return tag[:idx], tag_options(tag[idx+1:])
+ return tag[:idx], tagOptions(tag[idx+1:])
}
- return tag, tag_options("")
+ return tag, tagOptions("")
}
-func (opts tag_options) contains(option_name string) bool {
+func (opts tagOptions) contains(option_name string) bool {
if len(opts) == 0 {
return false
}