| 197 | } |
| 198 | |
| 199 | func (e *Encoder) Encode(v interface{}) error { |
| 200 | switch v := v.(type) { |
| 201 | case nil: |
| 202 | return e.EncodeNil() |
| 203 | case string: |
| 204 | return e.EncodeString(v) |
| 205 | case []byte: |
| 206 | return e.EncodeBytes(v) |
| 207 | case int: |
| 208 | return e.EncodeInt(int64(v)) |
| 209 | case int64: |
| 210 | return e.encodeInt64Cond(v) |
| 211 | case uint: |
| 212 | return e.EncodeUint(uint64(v)) |
| 213 | case uint64: |
| 214 | return e.encodeUint64Cond(v) |
| 215 | case bool: |
| 216 | return e.EncodeBool(v) |
| 217 | case float32: |
| 218 | return e.EncodeFloat32(v) |
| 219 | case float64: |
| 220 | return e.EncodeFloat64(v) |
| 221 | case time.Duration: |
| 222 | return e.encodeInt64Cond(int64(v)) |
| 223 | case time.Time: |
| 224 | return e.EncodeTime(v) |
| 225 | } |
| 226 | return e.EncodeValue(reflect.ValueOf(v)) |
| 227 | } |
| 228 | |
| 229 | func (e *Encoder) EncodeMulti(v ...interface{}) error { |
| 230 | for _, vv := range v { |