Skip to content

Instantly share code, notes, and snippets.

@bortzmeyer
Created March 17, 2010 21:54
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 bortzmeyer/335765 to your computer and use it in GitHub Desktop.
Save bortzmeyer/335765 to your computer and use it in GitHub Desktop.
func readShortInteger(buf *bytes.Buffer) (uint16, bool) {
slice := make([]byte, 2)
n, error := buf.Read(slice[0:2])
if error != nil || n != 2 {
if debug > 2 {
fmt.Printf("Error in Read of an int16: %s (%d bytes read)\n", error, n)
}
return 0, false
}
return binary.BigEndian.Uint16(slice[0:2]), true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment