|
|
|
|
|
by ainar-g
1309 days ago
|
|
I agree that this is a PITA, but this really is more of a growth pain than an initial design flaw. Contexts have appeared way after the Go 1.0, when the entire ecosystem has already gotten used to io.Reader and io.Writer. If you want a much more annoying example of inconsistency in the initial language design, look at the behaviour of nil and closed channels: - sending data to a nil channel blocks forever; - receiving data from a nil channel blocks forever; - sending data to a closed channel causes a panic; - receiving data from a closed channel is fine: you receive the zero value, forever. I can understand the logic behind the last two (sending to a closed channel is an error in program logic, and closing a channel is a common idiom for broadcasting completion of a task to several goroutines), but the first two are just a massive footgun, and, in my opinion, should cause panics instead. |
|