# HG changeset patch # User Sascha L. Teichmann # Date 1532120258 -7200 # Node ID c20e86a3c073286f2cc2ea41febca4d72eca38f6 # Parent e85413e5befafc8fdd34fc026275ee01a13f75c8 Made serialisation of sessions symmetrical. diff -r e85413e5befa -r c20e86a3c073 auth/connection.go --- a/auth/connection.go Fri Jul 20 22:50:59 2018 +0200 +++ b/auth/connection.go Fri Jul 20 22:57:38 2018 +0200 @@ -1,7 +1,6 @@ package auth import ( - "bytes" "database/sql" "encoding/binary" "errors" @@ -50,12 +49,15 @@ mu sync.Mutex } -func (c *Connection) serialize() []byte { - var buf bytes.Buffer - c.session.serialize(&buf) - access, _ := c.last().MarshalText() - binary.Write(&buf, binary.BigEndian, string(access)) - return buf.Bytes() +func (c *Connection) serialize(w io.Writer) error { + if err := c.session.serialize(w); err != nil { + return err + } + access, err := c.last().MarshalText() + if err == nil { + err = binary.Write(w, binary.BigEndian, string(access)) + } + return err } func (c *Connection) deserialize(r io.Reader) error {