aboutsummaryrefslogtreecommitdiff
path: root/conn.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-22 10:57:30 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-22 10:57:30 +0800
commit89db1e89f130e29cfb1b5d8b22821b55621d56b0 (patch)
tree30ca77cb40ca21a618d61a7a64d690e743e7cf70 /conn.go
parentUse Source by value instead of pointer (diff)
downloadgo-lindenii-irc-89db1e89f130e29cfb1b5d8b22821b55621d56b0.tar.gz
go-lindenii-irc-89db1e89f130e29cfb1b5d8b22821b55621d56b0.tar.zst
go-lindenii-irc-89db1e89f130e29cfb1b5d8b22821b55621d56b0.zip
ReadMessage should return the raw line too
Diffstat (limited to 'conn.go')
-rw-r--r--conn.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/conn.go b/conn.go
index ac3787c..1cd8492 100644
--- a/conn.go
+++ b/conn.go
@@ -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
}