Skip to content

Instantly share code, notes, and snippets.

@gorakhargosh
Forked from Jxck/rob.go
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gorakhargosh/50a44ec626af01d8ee5f to your computer and use it in GitHub Desktop.
Save gorakhargosh/50a44ec626af01d8ee5f to your computer and use it in GitHub Desktop.
gocon 2014
type errWriter struct {
w io.Writer
err error
}
func (e *errWriter) Write(p []byte) {
if e.err != nil {
return
}
_, e.err = e.w.Write(p)
}
func (e *errWriter) Err() error {
return e.err
}
func do() {
ew := &errWriter{w: ...}
ew.Write(buf)
ew.Write(buf)
...
...
if ew.Err() != nil {
return ew.Err()
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment