diff options
Diffstat (limited to 'ber/dump.go')
-rw-r--r-- | ber/dump.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ber/dump.go b/ber/dump.go index 64a2672..da2c8bf 100644 --- a/ber/dump.go +++ b/ber/dump.go @@ -1,9 +1,12 @@ package ber -import "fmt" +import ( + "bytes" + "fmt" +) func Dump(b []byte) string { - return dump(b, 0) + return dump(bytes.NewBuffer(b), 0) } func short(b []byte) string { @@ -13,8 +16,8 @@ func short(b []byte) string { return fmt.Sprint(b) } -func dump(b []byte, indent int) (s string) { - class, kind, tag, _, value, rest := Split(b) +func dump(r *bytes.Buffer, indent int) (s string) { + class, kind, tag, _, value := Split(r) s += fmt.Sprintf("%*s", indent*2, "") @@ -39,11 +42,11 @@ func dump(b []byte, indent int) (s string) { } if len(value) > 0 && kind != kindPrimitive { - s += dump(value, indent+1) + s += dump(bytes.NewBuffer(value), indent+1) } - if len(rest) > 0 { - s += dump(rest, indent) + if r.Len() > 0 { + s += dump(r, indent) } return } |