diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-22 10:57:30 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-22 10:57:30 +0800 |
commit | 89db1e89f130e29cfb1b5d8b22821b55621d56b0 (patch) | |
tree | 30ca77cb40ca21a618d61a7a64d690e743e7cf70 | |
parent | Use Source by value instead of pointer (diff) | |
download | go-lindenii-irc-89db1e89f130e29cfb1b5d8b22821b55621d56b0.tar.gz go-lindenii-irc-89db1e89f130e29cfb1b5d8b22821b55621d56b0.tar.zst go-lindenii-irc-89db1e89f130e29cfb1b5d8b22821b55621d56b0.zip |
ReadMessage should return the raw line too
-rw-r--r-- | conn.go | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -18,7 +18,7 @@ func NewConn(netConn net.Conn) Conn { } } -func (c *Conn) ReadMessage() (msg Message, err error) { +func (c *Conn) ReadMessage() (msg Message, line string, err error) { raw, err := c.bufReader.ReadSlice('\n') if err != nil { return @@ -28,7 +28,9 @@ func (c *Conn) ReadMessage() (msg Message, err error) { raw = raw[:len(raw) - 1] } - msg, err = Parse(slices.Clone(raw)) + lineBytes := slices.Clone(raw) + line = bytesToString(lineBytes) + msg, err = Parse(lineBytes) return } |