Skip to content

v1.10.0

Latest

Choose a tag to compare

@cmilesio cmilesio released this 17 Oct 00:30
7bb3368

GoDump v1.10.0 adds two opt-in ways to make dumps easier to read and control what they show.

Hide type annotations

Use WithoutTypes() to keep value colors and structure while omitting annotations such as #string, #int, and struct type names:

d := godump.NewDumper(godump.WithoutTypes(), godump.WithoutHeader())
d.Dump("hello")
// "hello"

Works with text, HTML, and diffs. Existing output stays unchanged unless the option is enabled. See #72, addressing #60.

Redact by serialization tags

Use WithRedactTags("json", "xml") to redact fields whose selected tag values equal "-". Call WithRedactTags() or WithRedactTags("*") to check every tag key.

type User struct {
    Name       string
    Credential string `json:"-"`
}

d := godump.NewDumper(
    godump.WithRedactTags("json"),
    godump.WithoutTypes(),
    godump.WithoutHeader(),
)
d.Dump(User{Name: "Alice", Credential: "secret"})
// {
//   +Name       => "Alice"
//   +Credential => <redacted>
// }

Redaction also applies to nested structs, embedded fields, and collections. Matching is exact and case-sensitive. JSON helpers keep their existing marshaling behavior; use WithDisableStringer(true) to redact struct fields even when the type defines a custom String() method. See #74, addressing #59.

Compatibility

  • Updated documentation and runnable examples.
  • Requires Go 1.18 or newer and has no external library dependencies.

Thanks to @marvinpeter95 for the original WithoutTypes() contribution in #65, which this release builds on.

Full changelog: v1.9.1...v1.10.0