write full message to new array for async buffer

This commit is contained in:
Joseph Lawson
2014-03-28 23:31:30 -04:00
parent 28f7078dbb
commit cc2dd53de8
+4 -2
View File
@@ -44,12 +44,14 @@ func (o *TCPOutput) worker() {
for {
conn.Write(<-o.buf)
conn.Write([]byte("¶"))
}
}
func (o *TCPOutput) Write(data []byte) (n int, err error) {
o.buf <- data
new_buf := make([]byte, len(data) + 2)
append(data, []byte("¶"))
copy(new_buf, data)
o.buf <- new_buf
return len(data), nil
}