google/flatbuffers

Go's GetBool() should check for `buf[0] != 0` instead of `buf[0] == 1`

Opened this issue · 0 comments

Go's GetBool() function checks whether a byte is == 1

// GetBool decodes a little-endian bool from a byte slice.
func GetBool(buf []byte) bool {
	return buf[0] == 1
}

This is inconsistent with rust, C++, PHP, Python and is not what I think of as the usual convention of integer-to-boolean conversion.

Alternatively: it could be made explicit that the only legal values for bytes storing booleans are 0 and 1; currently the internals doc is not explicit and no verifiers I have looked at will reject a boolean of (say) 2.