MCPcopy
hub / github.com/tinylib/msgp / ReadBoolBytes

Function ReadBoolBytes

msgp/read_bytes.go:391–403  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

389// - [ErrShortBytes] (too few bytes)
390// - [TypeError] (not a bool)
391func 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.

Callers 5

TestReadBoolBytesFunction · 0.85
BenchmarkReadBoolBytesFunction · 0.85
FuzzReadBytesFunction · 0.85
rwBoolBytesFunction · 0.85
readIntfBytesDepthFunction · 0.85

Calls 1

badPrefixFunction · 0.85

Tested by 3

TestReadBoolBytesFunction · 0.68
BenchmarkReadBoolBytesFunction · 0.68
FuzzReadBytesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…