Closed msabramo closed 8 years ago
Just curious. Any feedback on this?
A better way to do this would probably be
jsonStr := string(jsonRaw)
if strings.HasSuffix(jsonStr, "\n") {
fmt.Fprintf(c.Out, jsonStr)
} else {
fmt.Fprintf(c.Out, jsonStr + "\n")
}
so that we never add unnecessary newlines.
@siddharthist: Great idea! I just updated it, as you suggested.
I think it would be nice if the output always ended with a newline. It's weird when it doesn't because the next prompt starts on the same line as the last line of output and that just doesn't look great. Also it's nice to have the output end with a newline because then you can redirect to a file and have that file adhere to POSIX standards - e.g.:
Fixes: GH-23
Before
Note how in the first example, the prompt appears on the same line as the last closing brace and in the second example, the
*** END services ***
appears immediately after the last closing brace.After