davecgh / go-spew

Implements a deep pretty printer for Go data structures to aid in debugging
ISC License
5.97k stars 361 forks source link

make nil maps appear different than empty maps #24

Closed deads2k closed 9 years ago

deads2k commented 9 years ago

Currently, both nil maps and empty maps appear as:

(map[string]int)map[]

This is very confusing when debugging. This change makes nil maps appear as:

(map[string]int)<nil>
coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.02%) when pulling c1d30c395939b607259e839aad189b8f9279f1eb on deads2k:deads-fix-nil-map-output into 83f84dc933714d51504ceed59f43ead21d096fe7 on davecgh:master.

davecgh commented 9 years ago

Thanks for the pr. This seems like a good change. However, can you update it for the Dump output too? I'd like to keep their behavior in sync.

deads2k commented 9 years ago

Updated Dump and used break instead of if/else in both format.go and dump.go

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.03%) when pulling 1aaf839fb07e099361e445273993ccd9adc21b07 on deads2k:deads-fix-nil-map-output into 83f84dc933714d51504ceed59f43ead21d096fe7 on davecgh:master.

deads2k commented 9 years ago

@davecgh bump