As an example, to clarify my question, in Google Go 1.0, the following interface is defined in the io package:
type Reader interface { Read(p []byte) (n int, err error) }
Especially changes the list of parameters (n int, err error) . In fact, the number of bytes cannot be negative, according to the interface documentation:
Returns the number of bytes read (0 <= n <= len (p)) [...]
In C, the reason for using int was an in-band value of -1 to signal an error (see Effective Transition: Multiple Return Values ). Due to the many return values, special in-band values ββare not needed.
There is a type uint in Go 1.0.
What is the specific reason for using int compared to uint in the case of values ββthat use only the positive range [0, β) without the need for special in-band values?
source share