Skip to content

Instantly share code, notes, and snippets.

@pulkitkumar
Last active August 13, 2018 07:06
Show Gist options
  • Save pulkitkumar/f47b32237905725c33591409056bdf1f to your computer and use it in GitHub Desktop.
Save pulkitkumar/f47b32237905725c33591409056bdf1f to your computer and use it in GitHub Desktop.
Simple error handling
n, err := io.ReadAtLeast(r, buf, min)
if err != nil {
switch err {
case io.ErrShortBuffer:
// handle short buffer error
break
case io.ErrUnexpectedEOF:
// handle short buffer error
break
default:
// handle other errors
}
}
// use n ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment