Support ignoring and hashing fields

This commit is contained in:
Matthew Quigley 2019-08-27 16:07:30 -07:00
parent dd244ad083
commit c4b86eeb3b
1 changed files with 16 additions and 6 deletions

View File

@ -412,18 +412,28 @@ func (d *dumpState) dump(v reflect.Value) {
} else {
vt := v.Type()
numFields := v.NumField()
writeComma := false
writeNewline := false
for i := 0; i < numFields; i++ {
d.indent()
vtf := vt.Field(i)
tag := vtf.Tag.Get("spew")
if tag == "-" {
continue
}
if writeComma {
d.w.Write(commaNewlineBytes)
writeComma = false
}
writeComma = true
writeNewline = true
d.indent()
d.w.Write([]byte(vtf.Name))
d.w.Write(colonSpaceBytes)
d.ignoreNextIndent = true
d.dump(d.unpackValue(v.Field(i)))
if i < (numFields - 1) {
d.w.Write(commaNewlineBytes)
} else {
d.w.Write(newlineBytes)
}
}
if writeNewline {
d.w.Write(newlineBytes)
}
}
d.depth--