Skip to content

Commit 8fdae4a

Browse files
committed
compact json and add \n delimiter for d4 piping
1 parent c779f58 commit 8fdae4a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

d4-tlsf.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,17 @@ func output(t d4tls.TLSSession) {
463463
} else {
464464
panic(fmt.Sprintf("./%s does not exist", *outJSON))
465465
}
466-
// If not folder specidied, we output to stdout
466+
// If not folder specified, we output to stdout
467467
} else {
468-
r := bytes.NewReader(jsonRecord)
469-
_, err := io.Copy(os.Stdout, r)
470-
if err != nil {
468+
var buf bytes.Buffer
469+
if err := json.Compact(&buf, jsonRecord); err != nil {
470+
fmt.Println("Failed to compact json output")
471+
}
472+
if _, err := buf.Write([]byte{0x0A}); err != nil {
473+
fmt.Println("Could not append delimiter")
474+
}
475+
476+
if _, err := io.Copy(os.Stdout, &buf); err != nil {
471477
panic("Could not write to stdout.")
472478
}
473479
}

0 commit comments

Comments
 (0)