NextType returns the type of the next object in the slice. If the length of the input is zero, it returns [InvalidType].
(b []byte)
| 16 | // of the input is zero, it returns |
| 17 | // [InvalidType]. |
| 18 | func NextType(b []byte) Type { |
| 19 | if len(b) == 0 { |
| 20 | return InvalidType |
| 21 | } |
| 22 | spec := getBytespec(b[0]) |
| 23 | t := spec.typ |
| 24 | if t == ExtensionType && len(b) > int(spec.size) { |
| 25 | var tp int8 |
| 26 | if spec.extra == constsize { |
| 27 | tp = int8(b[1]) |
| 28 | } else { |
| 29 | tp = int8(b[spec.size-1]) |
| 30 | } |
| 31 | switch tp { |
| 32 | case TimeExtension, MsgTimeExtension: |
| 33 | return TimeType |
| 34 | case Complex128Extension: |
| 35 | return Complex128Type |
| 36 | case Complex64Extension: |
| 37 | return Complex64Type |
| 38 | default: |
| 39 | return ExtensionType |
| 40 | } |
| 41 | } |
| 42 | return t |
| 43 | } |
| 44 | |
| 45 | // IsNil returns true if len(b)>0 and |
| 46 | // the leading byte is a 'nil' MessagePack |
searching dependent graphs…