(typ reflect.Type, version int16, flexible bool, tag structTag)
| 374 | ) |
| 375 | |
| 376 | func encodeFuncOf(typ reflect.Type, version int16, flexible bool, tag structTag) encodeFunc { |
| 377 | if reflect.PtrTo(typ).Implements(writerTo) { |
| 378 | return writerEncodeFuncOf(typ) |
| 379 | } |
| 380 | switch typ.Kind() { |
| 381 | case reflect.Bool: |
| 382 | return (*encoder).encodeBool |
| 383 | case reflect.Int8: |
| 384 | return (*encoder).encodeInt8 |
| 385 | case reflect.Int16: |
| 386 | return (*encoder).encodeInt16 |
| 387 | case reflect.Int32: |
| 388 | return (*encoder).encodeInt32 |
| 389 | case reflect.Int64: |
| 390 | return (*encoder).encodeInt64 |
| 391 | case reflect.Float64: |
| 392 | return (*encoder).encodeFloat64 |
| 393 | case reflect.String: |
| 394 | return stringEncodeFuncOf(flexible, tag) |
| 395 | case reflect.Struct: |
| 396 | return structEncodeFuncOf(typ, version, flexible) |
| 397 | case reflect.Slice: |
| 398 | if typ.Elem().Kind() == reflect.Uint8 { // []byte |
| 399 | return bytesEncodeFuncOf(flexible, tag) |
| 400 | } |
| 401 | return arrayEncodeFuncOf(typ, version, flexible, tag) |
| 402 | default: |
| 403 | panic("unsupported type: " + typ.String()) |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | func stringEncodeFuncOf(flexible bool, tag structTag) encodeFunc { |
| 408 | switch { |
no test coverage detected