> The language specification is careful to state sizes for many types,
> but it doesn't for bool. I checked and of course it's 1 byte as it
> should be. However, if you're interfacing with C code and want to let
> it write into an array of Go bools, it becomes rather important that
> the size not change in a later revision of the language. I've love to
> see a line in the language specification that makes
> unsafe.sizeof(true) == 1 explicit.
If you want to assume this, fine, but you need to accept
in doing so that it is an unsafe assumption and might not
be true in the future. Similarly, if you assume that
sizeof(int) == 4 or that sizeof(Go's int) == sizeof(C's int)
your code might also break in the future.
If you need to make these assumptions for performance
reasons, then document and live with them.
But if you don't need the performance, it would be safer to
write correct code that copies the array from C types
to Go types and back. For example, see
http://golang.org/src/pkg/syscall/syscall_linux.go#L66
which is careful not to assume that C's gid_t and
Go's int are the same size, even though in practice
they often are.
Russ