New builds a new section block with the specified type, version, optional length and size.
(typ Type, ver capver.Version, l, size uint32)
| 34 | |
| 35 | // New builds a new section block with the specified type, version, optional length and size. |
| 36 | func New(typ Type, ver capver.Version, l, size uint32) Section { |
| 37 | var s Section |
| 38 | s[0] = uint8(typ) |
| 39 | s[1] = uint8(ver) |
| 40 | copy(s[2:6], bytes.WriteUint32(l)) |
| 41 | copy(s[6:], bytes.WriteUint32(size)) |
| 42 | return s |
| 43 | } |
| 44 | |
| 45 | // Read reads the section from the byte slice. |
| 46 | func Read(b []byte) Section { |