3 ms·
One downside to this is that doesn't work for functions those return values aren't disjoint. io.Reader is an example where the function can return io.EOF and s
by atombender 7y ago
One downside to this is that doesn't work for functions those return values aren't disjoint.
io.Reader is an example where the function can return io.EOF and still returns valid data together with a count in its first return value. If it returns a count > 0, the buffer has valid data. A lot of Go projects get this wrong because it's not obvious -- it goes against the behaviour of almost all Go functions.
Go is unfortunately full of little surprising warts like this where you have to tread super carefully. Nil channels is one of my favorites.
- frou_dh 7y agoWhat a thorn the design of that Read method is, because it has caused perennial FUD against the validity of sum typing in Go circles.
- atombender 7y agoHas it come up a lot in Go proposals discussions?
- frou_dh 7y agoDunno, I meant reddit flamewars etc.