From bb0b5605422ad0fada5473ea7cb330a935a3a72f Mon Sep 17 00:00:00 2001 From: Jim Teeuwen Date: Wed, 29 Jan 2014 01:37:15 +0100 Subject: [PATCH] Fixes bytewriter to format output. --- bytewriter.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bytewriter.go b/bytewriter.go index c9b602c..ae9cbd3 100644 --- a/bytewriter.go +++ b/bytewriter.go @@ -9,7 +9,11 @@ import ( "io" ) -var newline = []byte{'\n'} +var ( + newline = []byte{'\n'} + dataindent = []byte{'\t', '\t'} + space = []byte{' '} +) type ByteWriter struct { io.Writer @@ -24,7 +28,10 @@ func (w *ByteWriter) Write(p []byte) (n int, err error) { for n = range p { if w.c%12 == 0 { w.Writer.Write(newline) + w.Writer.Write(dataindent) w.c = 0 + } else { + w.Writer.Write(space) } fmt.Fprintf(w.Writer, "0x%02x,", p[n])