Bool encodes and writes a bool value into the element bitstream, and then returns the bool value. For simple, 2-alternative encodings, the idiomatic way to call Bool is something like: if w.Bool(x != 0) { // alternative #1 } else { // alternative #2 } For multi-alternative encodings, use C
(b bool)
| 265 | // |
| 266 | // For multi-alternative encodings, use Code instead. |
| 267 | func (w *Encoder) Bool(b bool) bool { |
| 268 | w.Sync(SyncBool) |
| 269 | var x byte |
| 270 | if b { |
| 271 | x = 1 |
| 272 | } |
| 273 | err := w.Data.WriteByte(x) |
| 274 | w.checkErr(err) |
| 275 | return b |
| 276 | } |
| 277 | |
| 278 | // Int64 encodes and writes an int64 value into the element bitstream. |
| 279 | func (w *Encoder) Int64(x int64) { |