BoolValues converts the lazily-decoded field data into a []bool. Since Protobuf encodes boolean values as integers, any varint-encoded integer value is valid. A value of zero is treated as false and any non-zero value is treated as true. See the [FieldData] docs for more specific details about int
()
| 83 | // |
| 84 | // See the [FieldData] docs for more specific details about interpreting lazily-decoded data. |
| 85 | func (fd *FieldData) BoolValues() ([]bool, error) { |
| 86 | if fd == nil || len(fd.data) == 0 { |
| 87 | return nil, ErrTagNotFound |
| 88 | } |
| 89 | s, err := sliceValue(fd, csproto.WireTypeVarint, fd.boolSlice, func(data []byte) (bool, int, error) { |
| 90 | v, n, err := csproto.DecodeVarint(data) |
| 91 | if err != nil { |
| 92 | return false, 0, err |
| 93 | } |
| 94 | return v != 0, n, nil |
| 95 | }) |
| 96 | if fd.unsafe { |
| 97 | fd.maxCap = max(fd.maxCap, cap(s)) |
| 98 | fd.boolSlice = s |
| 99 | } |
| 100 | return s, err |
| 101 | } |
| 102 | |
| 103 | // StringValue converts the lazily-decoded field data into a string. |
| 104 | // |