From dc95f64ebe89c57c304e09b4a3fdc212c30b12ce Mon Sep 17 00:00:00 2001 From: Tom Hudson Date: Thu, 5 Jul 2018 10:11:16 +0000 Subject: [PATCH] Trims whitespace on monochrome output; fixes #43 --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 58009e2..5437ada 100644 --- a/main.go +++ b/main.go @@ -370,6 +370,13 @@ func ungron(r io.Reader, w io.Writer, opts int) (int, error) { } } + // For whatever reason, the monochrome version of the JSON + // has a trailing newline character, but the colorized version + // does not. Strip the whitespace so that neither has the newline + // character on the end, and then we'll add a newline in the + // Fprintf below + j = bytes.TrimSpace(j) + fmt.Fprintf(w, "%s\n", j) return exitOK, nil