godump is a developer-friendly, zero-dependency debug dumper for Go. It provides pretty, colorized terminal output of your structs, slices, maps, and more - complete with cyclic reference detection and control character escaping.
Inspired by Symfony's VarDumper which is used in Laravel's tools like dump() and dd().
Terminal Output Example (Kitchen Sink)
| Feature | godump | go-spew | pp |
|---|---|---|---|
| Zero dependencies | ✅ | ❌ | ❌ |
| Colorized terminal output | ✅ | ✅ | ✅ |
| HTML output | ✅ | ❌ | ❌ |
JSON output helpers (DumpJSON, DumpJSONStr) |
✅ | ❌ | ❌ |
Dump to io.Writer |
✅ | ✅ | ✅ |
| Shows file + line number of dump call | ✅ | ❌ | ❌ |
| Cyclic reference detection | ✅ | ❌ | |
| Handles unexported struct fields | ✅ | ✅ | ✅ |
Visibility markers (+ / -) |
✅ | ❌ | ❌ |
| Max depth control | ✅ | ❌ | ❌ |
| Max items (slice/map truncation) | ✅ | ❌ | ❌ |
| Max string length truncation | ✅ | ❌ | ❌ |
Dump & Die (dd() equivalent) |
✅ | ❌ | ❌ |
| Control character escaping | ✅ | ||
| Supports structs, maps, slices, pointers, interfaces | ✅ | ✅ | ✅ |
Pretty type name rendering (#package.Type) |
✅ | ❌ | ❌ |
| Builder-style configuration API | ✅ | ❌ | ❌ |
Test-friendly string output (DumpStr, DumpHTML, DumpJSONStr) |
✅ | ✅ | ✅ |
| HTML / Web UI debugging support | ✅ | ❌ | ❌ |
If you'd like to suggest improvements or additional comparisons, feel free to open an issue or PR.
go get github.com/goforj/godumptype User struct { Name string }
godump.Dump(User{Name: "Alice"})
// #main.User {
// +Name => "Alice" #string
// } godump.DumpStr(v) // return as string
godump.DumpHTML(v) // return HTML output
godump.DumpJSON(v) // print JSON directly
godump.Fdump(w, v) // write to io.Writer
godump.Dd(v) // dump + exitgodump aims for simple usage with sensible defaults out of the box, but also provides a flexible builder-style API for customization.
If you want to heavily customize the dumper behavior, you can create a Dumper instance with specific options:
godump.NewDumper(
godump.WithMaxDepth(15), // default: 15
godump.WithMaxItems(100), // default: 100
godump.WithMaxStringLen(100000), // default: 100000
godump.WithWriter(os.Stdout), // default: os.Stdout
godump.WithSkipStackFrames(10), // default: 10
godump.WithDisableStringer(false), // default: false
).Dump(v)All runnable examples can be found under ./examples:
- Basic usage →
examples/basic/main.go - Extended usage →
examples/extended/main.go - Kitchen sink →
examples/kitchensink/main.go - Builder API →
examples/builder/main.go
📘 How to Read the Output
godump output is designed for clarity and traceability. Here's how to interpret its structure:
<#dump // main.go:26- The first line shows the file and line number where
godump.Dump()was invoked. - Helpful for finding where the dump happened during debugging.
#main.User- Fully qualified struct name with its package path.
+Name => "Alice"
-secret => "..."+→ Exported (public) field-→ Unexported (private) field (accessed reflectively)
If a pointer has already been printed:
↩︎ &1- Prevents infinite loops in circular structures
- References point back to earlier object instances
0 => "value"
a => 1- Array/slice indices and map keys are shown with
=>formatting and indentation - Slices and maps are truncated if
maxItemsis exceeded
"Line1\nLine2\tDone"- Control characters like
\n,\t,\r, etc. are safely escaped - Strings are truncated after
maxStringLenrunes
- ✅ Structs (exported & unexported)
- ✅ Pointers, interfaces
- ✅ Maps, slices, arrays
- ✅ Channels, functions
- ✅ time.Time (nicely formatted)
MIT © goforj

