Add docs for MessageReader

pgx-vs-pq
Jack Christensen 2013-07-15 08:30:02 -05:00
parent df0a537f59
commit 462df934ab
1 changed files with 3 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/binary"
)
// MessageReader is a helper that reads values from a PostgreSQL message.
type MessageReader struct {
buf *bytes.Buffer
}
@ -37,6 +38,7 @@ func (r *MessageReader) ReadOid() Oid {
return Oid(binary.BigEndian.Uint32(r.buf.Next(4)))
}
// ReadString reads a null terminated string
func (r *MessageReader) ReadString() string {
b, err := r.buf.ReadBytes(0)
if err != nil {
@ -45,7 +47,7 @@ func (r *MessageReader) ReadString() string {
return string(b[:len(b)-1])
}
// Read count bytes and return as string
// ReadByteString reads count bytes and return as string
func (r *MessageReader) ReadByteString(count int32) string {
return string(r.buf.Next(int(count)))
}