Skip to content

Commit

Permalink
Make awsutil.Prettify more friendly for blobs (#943)
Browse files Browse the repository at this point in the history
* Make awsutil.Prettify more friendly for blobs

Change the current behavior of the prettifier for `[]byte`:
```
Data: [
  42,
  36,
  69,
  1
]
```
With something more friendly:
```
Data: <binary>
```

* Update example to reflect awsutil.Prettify change

* Add blob length to awsutil.Prettify
  • Loading branch information
fsenart authored and xibz committed Nov 18, 2016
1 parent 7fd725d commit 744a71d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions aws/awsutil/prettify.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ func prettify(v reflect.Value, indent int, buf *bytes.Buffer) {

buf.WriteString("\n" + strings.Repeat(" ", indent) + "}")
case reflect.Slice:
strtype := v.Type().String()
if strtype == "[]uint8" {
fmt.Fprintf(buf, "<binary> len %d", v.Len())
break
}

nl, id, id2 := "", "", ""
if v.Len() > 3 {
nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ExampleMarshal() {
// Output:
// err <nil>
// Bytes {
// B: [48,49]
// B: <binary> len 2
// }
// MyField {
// S: "MyFieldValue"
Expand Down

0 comments on commit 744a71d

Please sign in to comment.