Created
March 17, 2010 21:54
-
-
Save bortzmeyer/335765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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