From 24f8f91323ae42ffde8ba9ed79e9a0dfd478f4b6 Mon Sep 17 00:00:00 2001 From: Timo Genzmer Date: Tue, 21 Jan 2020 11:13:36 +0100 Subject: [PATCH] scan stdin by byte instead of line --- tee.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tee.go b/tee.go index ef858da..15a22f3 100644 --- a/tee.go +++ b/tee.go @@ -3,10 +3,8 @@ package main import ( "bufio" "bytes" - "fmt" - "io" - "github.com/mattn/go-colorable" + "io" ) func tee(stdin io.Reader, stdout io.Writer) string { @@ -15,8 +13,9 @@ func tee(stdin io.Reader, stdout io.Writer) string { tee := io.TeeReader(stdin, &b1) s := bufio.NewScanner(tee) + s.Split(bufio.ScanBytes) for s.Scan() { - fmt.Fprintln(stdout, s.Text()) + stdout.Write(s.Bytes()) } uncolorize := colorable.NewNonColorable(&b2)