pad returns the number of bytes of padding, based on current position and additional offset. and alignment.
(offset, algn int)
| 50 | // pad returns the number of bytes of padding, based on current position and additional offset. |
| 51 | // and alignment. |
| 52 | func (enc *encoder) padding(offset, algn int) int { |
| 53 | abs := enc.pos + offset |
| 54 | if abs%algn != 0 { |
| 55 | newabs := (abs + algn - 1) & ^(algn - 1) |
| 56 | return newabs - abs |
| 57 | } |
| 58 | return 0 |
| 59 | } |
| 60 | |
| 61 | // Calls binary.Write(enc.out, enc.order, v) and panics on write errors. |
| 62 | func (enc *encoder) binwrite(v any) { |