From 98ea36235a92e72060b7def42b7181cd3d9cb2df Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 1 Mar 2021 17:24:21 -0500 Subject: [PATCH] IRCReader: trim \r if the line ending was \r\n For parity with (*bufio.Reader).ReadLine(), which does the same --- ircreader/ircreader.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ircreader/ircreader.go b/ircreader/ircreader.go index 4411fac..204345d 100644 --- a/ircreader/ircreader.go +++ b/ircreader/ircreader.go @@ -63,6 +63,10 @@ func (cc *IRCReader) ReadLine() ([]byte, error) { line := cc.buf[cc.start : cc.searchFrom+nlidx] cc.start = cc.searchFrom + nlidx + 1 cc.searchFrom = cc.start + // treat \r\n as the line terminator if it was present + if 0 < len(line) && line[len(line)-1] == '\r' { + line = line[:len(line)-1] + } return line, nil }