github goforj/godump v1.10.0

one month ago

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 follows traversal through nested and embedded structs and collections. Matching is exact and case-sensitive. JSON helpers keep their existing marshaling behavior; use WithDisableStringer(true) when tagged structs need field traversal instead of custom String() output. See #74, addressing #59.

Maintenance and compatibility

  • Updated documentation, generated runnable examples, and development commands.
  • Added repository security and supply-chain checks and refined dependency maintenance.
  • Retained Go 1.18 compatibility, zero external library dependencies, and 100% main-package statement coverage.

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

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

Don't miss a new godump release

NewReleases is sending notifications on new releases.