Mercurial > gemma
view auth/encode.go @ 315:3ef0521609f5
Limit is not needed when fetching an email for a user.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 02 Aug 2018 10:03:54 +0200 |
parents | f345edb409b2 |
children |
line wrap: on
line source
package auth import ( "encoding/binary" "io" ) type binReader struct { r io.Reader err error } func (r *binReader) read(x interface{}) { if r.err == nil { r.err = binary.Read(r.r, binary.BigEndian, x) } } func (r *binReader) readString(s *string) { if r.err != nil { return } var l uint32 if r.err = binary.Read(r.r, binary.BigEndian, &l); r.err != nil { return } b := make([]byte, l) if r.err = binary.Read(r.r, binary.BigEndian, b); r.err != nil { return } *s = string(b) } type binWriter struct { w io.Writer err error } func (w *binWriter) write(x interface{}) { if w.err == nil { w.err = binary.Write(w.w, binary.BigEndian, x) } } func (w *binWriter) writeString(s string) { if w.err == nil { w.err = binary.Write(w.w, binary.BigEndian, uint32(len(s))) } if w.err == nil { w.err = binary.Write(w.w, binary.BigEndian, []byte(s)) } }