4 ms·
Yea that's probably an artifact of a C code. The correct way to handle this in go ( i think, i'm a beginner like everyone else ) is to pass around a request str
by xal 17y ago
Yea that's probably an artifact of a C code. The correct way to handle this in go ( i think, i'm a beginner like everyone else ) is to pass around a request struct that contains an error channel and have the main connection handling gorutine select on this.
That's at least for bigger picture errors. On the method level you should use multiple return values to indicate erros (usually as last return value).
So r, err = write(y) { if (err!=nil) { request.errors <- err; return } }
- dlsspy 17y agoThe most important part is to stop doing the thing that isn't working. If I communicate this to the channel and the channel is read by the current goroutine, then the channel's buffer must be large enough to handle the total number of errors that may occur in a single invocation or the goroutine will deadlock on itself.