From 24f8f91323ae42ffde8ba9ed79e9a0dfd478f4b6 Mon Sep 17 00:00:00 2001 From: Timo Genzmer Date: Tue, 21 Jan 2020 11:13:36 +0100 Subject: [PATCH 1/2] 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) From 44c9603edc3f6416382789f887ba56bb69bc7ef4 Mon Sep 17 00:00:00 2001 From: Timo Genzmer Date: Thu, 5 Mar 2020 15:06:18 +0100 Subject: [PATCH 2/2] format imports --- tee.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tee.go b/tee.go index 15a22f3..5aa17d9 100644 --- a/tee.go +++ b/tee.go @@ -3,8 +3,9 @@ package main import ( "bufio" "bytes" - "github.com/mattn/go-colorable" "io" + + "github.com/mattn/go-colorable" ) func tee(stdin io.Reader, stdout io.Writer) string {