|
7 | 7 | //
|
8 | 8 | // Numbers are translated by reading and writing fixed-size values.
|
9 | 9 | // A fixed-size value is either a fixed-size arithmetic
|
10 |
| -// type (int8, uint8, int16, float32, complex64, ...) |
| 10 | +// type (bool, int8, uint8, int16, float32, complex64, ...) |
11 | 11 | // or an array or struct containing only fixed-size values.
|
12 | 12 | //
|
13 | 13 | // The varint functions encode and decode single integer values using
|
@@ -147,6 +147,8 @@ func (bigEndian) GoString() string { return "binary.BigEndian" }
|
147 | 147 | // of fixed-size values.
|
148 | 148 | // Bytes read from r are decoded using the specified byte order
|
149 | 149 | // and written to successive fields of the data.
|
| 150 | +// When decoding boolean values, a zero byte is decoded as false, and |
| 151 | +// any other non-zero byte is decoded as true. |
150 | 152 | // When reading into structs, the field data for fields with
|
151 | 153 | // blank (_) field names is skipped; i.e., blank field names
|
152 | 154 | // may be used for padding.
|
@@ -249,6 +251,7 @@ func Read(r io.Reader, order ByteOrder, data interface{}) error {
|
249 | 251 | // Write writes the binary representation of data into w.
|
250 | 252 | // Data must be a fixed-size value or a slice of fixed-size
|
251 | 253 | // values, or a pointer to such data.
|
| 254 | +// Boolean values encode as one byte: 1 for true, and 0 for false. |
252 | 255 | // Bytes written to w are encoded using the specified byte order
|
253 | 256 | // and read from successive fields of the data.
|
254 | 257 | // When writing structs, zero values are written for fields
|
|
0 commit comments