MCPcopy
hub / github.com/TarsCloud/TarsGo / ReadInt8

Method ReadInt8

tars/protocol/codec/codec.go:612–634  ·  view source on GitHub ↗

ReadInt8 reads the int8 data for the tag and the require or optional sign.

(data *int8, tag byte, require bool)

Source from the content-addressed store, hash-verified

610
611// ReadInt8 reads the int8 data for the tag and the require or optional sign.
612func (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.
637func (b *Reader) ReadUint8(data *uint8, tag byte, require bool) error {

Callers 5

ReadBoolMethod · 0.95
TestInt8Function · 0.80
ReadFromMethod · 0.80
ReadFromMethod · 0.80
getBaseMethod · 0.80

Calls 4

SkipToNoCheckMethod · 0.95
bReadU8Function · 0.85
getTypeStrFunction · 0.85
ErrorfMethod · 0.45

Tested by 1

TestInt8Function · 0.64