Skip to content

Commit 90c9218

Browse files
committed
Fix remove '\n' before monkey on input-tcp mode
1 parent 251e45a commit 90c9218

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

input_tcp.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ func (i *TCPInput) handleConnection(conn net.Conn) {
117117

118118
if bytes.Equal(payloadSeparatorAsBytes[1:], line) {
119119
// unread the '\n' before monkeys
120-
buffer.UnreadByte()
120+
if buffer.Len() > 0 {
121+
buffer.Truncate(buffer.Len() - 1)
122+
}
121123
var msg Message
122124
msg.Meta, msg.Data = payloadMetaWithBody(buffer.Bytes())
123125
i.data <- &msg

0 commit comments

Comments
 (0)