Skip to content

Commit b43384e

Browse files
committed
encoding/binary: document the new bool support
Updates #16856 Change-Id: I57af6b0c0d5ecdaf19cf6f969b05ec9ec03058f1 Reviewed-on: https://go-review.googlesource.com/33756 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 5dd4d6e commit b43384e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/encoding/binary/binary.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// Numbers are translated by reading and writing fixed-size values.
99
// 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, ...)
1111
// or an array or struct containing only fixed-size values.
1212
//
1313
// The varint functions encode and decode single integer values using
@@ -147,6 +147,8 @@ func (bigEndian) GoString() string { return "binary.BigEndian" }
147147
// of fixed-size values.
148148
// Bytes read from r are decoded using the specified byte order
149149
// 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.
150152
// When reading into structs, the field data for fields with
151153
// blank (_) field names is skipped; i.e., blank field names
152154
// may be used for padding.
@@ -249,6 +251,7 @@ func Read(r io.Reader, order ByteOrder, data interface{}) error {
249251
// Write writes the binary representation of data into w.
250252
// Data must be a fixed-size value or a slice of fixed-size
251253
// values, or a pointer to such data.
254+
// Boolean values encode as one byte: 1 for true, and 0 for false.
252255
// Bytes written to w are encoded using the specified byte order
253256
// and read from successive fields of the data.
254257
// When writing structs, zero values are written for fields

0 commit comments

Comments
 (0)