ReadBoolBytes tries to read a bool from 'b' and return the value and the remaining bytes. Possible errors: - [ErrShortBytes] (too few bytes) - [TypeError] (not a bool)
(b []byte)
| 389 | // - [ErrShortBytes] (too few bytes) |
| 390 | // - [TypeError] (not a bool) |
| 391 | func ReadBoolBytes(b []byte) (bool, []byte, error) { |
| 392 | if len(b) < 1 { |
| 393 | return false, b, ErrShortBytes |
| 394 | } |
| 395 | switch b[0] { |
| 396 | case mtrue: |
| 397 | return true, b[1:], nil |
| 398 | case mfalse: |
| 399 | return false, b[1:], nil |
| 400 | default: |
| 401 | return false, b, badPrefix(BoolType, b[0]) |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | // ReadDurationBytes tries to read a time.Duration |
| 406 | // from 'b' and return the value and the remaining bytes. |
searching dependent graphs…