ReadInt8 reads the int8 data for the tag and the require or optional sign.
(data *int8, tag byte, require bool)
| 610 | |
| 611 | // ReadInt8 reads the int8 data for the tag and the require or optional sign. |
| 612 | func (b *Reader) ReadInt8(data *int8, tag byte, require bool) error { |
| 613 | have, ty, err := b.SkipToNoCheck(tag, require) |
| 614 | if err != nil { |
| 615 | return err |
| 616 | } |
| 617 | if !have { |
| 618 | return nil |
| 619 | } |
| 620 | switch ty { |
| 621 | case ZeroTag: |
| 622 | *data = 0 |
| 623 | case BYTE: |
| 624 | var tmp uint8 |
| 625 | err = bReadU8(b.buf, &tmp) |
| 626 | *data = int8(tmp) |
| 627 | default: |
| 628 | return fmt.Errorf("read 'int8' type mismatch, tag:%d, get type:%s", tag, getTypeStr(int(ty))) |
| 629 | } |
| 630 | if err != nil { |
| 631 | err = fmt.Errorf("read 'int8' tag:%d error:%v", tag, err) |
| 632 | } |
| 633 | return err |
| 634 | } |
| 635 | |
| 636 | // ReadUint8 reads the uint8 for the tag and the require or optional sign. |
| 637 | func (b *Reader) ReadUint8(data *uint8, tag byte, require bool) error { |