Split ReadBinary into ReadBinary/ReadBinaryPtr.

This commit is contained in:
Jae Kwon
2015-06-26 16:43:41 -07:00
parent 9965dd5de6
commit 6781b21d32
5 changed files with 26 additions and 15 deletions

View File

@ -5,16 +5,16 @@ import "io"
// String
func WriteString(s string, w io.Writer, n *int64, err *error) {
WriteUvarint(uint(len(s)), w, n, err)
WriteVarint(len(s), w, n, err)
WriteTo([]byte(s), w, n, err)
}
func ReadString(r io.Reader, n *int64, err *error) string {
length := ReadUvarint(r, n, err)
length := ReadVarint(r, n, err)
if *err != nil {
return ""
}
buf := make([]byte, int(length))
buf := make([]byte, length)
ReadFull(buf, r, n, err)
return string(buf)
}