Skip to content

Commit

Permalink
Merge pull request #25 from denniszl/master
Browse files Browse the repository at this point in the history
Update the map printer to properly print maps.
  • Loading branch information
k0kubun committed Sep 26, 2017
2 parents 4408878 + 87bc8d8 commit e057ee7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var (
// If the length of array or slice is larger than this,
// the buffer will be shorten as {...}.
BufferFoldThreshold = 1024
// PrintMapTypes when set to true will have map types will always appended to maps.
PrintMapTypes = true
)

func format(object interface{}) string {
Expand Down Expand Up @@ -155,7 +157,11 @@ func (p *printer) printMap() {
}
p.visited[p.value.Pointer()] = true

p.println("{")
if PrintMapTypes {
p.printf("%s{", p.typeString())
} else {
p.println("{")
}
p.indented(func() {
keys := p.value.MapKeys()
for i := 0; i < p.value.Len(); i++ {
Expand Down

0 comments on commit e057ee7

Please sign in to comment.