Dapper is not intended to be used directly as a debugging tool, but as a library for applications that need to describe Go values to humans, such as testing frameworks.
Some features and design goals include:
- Concise formatting, without type ambiguity
- Deterministic output, useful for generating diffs using standard tools
- A filter system for producing customized output on a per-value basis
This example renders a basic tree structure. Note that the output only includes type names where the value's type can not be inferred from the context.
package main
import (
"fmt"
"github.com/dogmatiq/dapper"
)
type TreeNode struct {
Name string
Value any
Children []*TreeNode
}
type NodeValue struct{}
func main() {
v := TreeNode{
Name: "root",
Children: []*TreeNode{
{
Name: "branch #1",
Value: 100,
},
{
Name: "branch #2",
Value: NodeValue{},
},
},
}
dapper.Print(v)
}
main.TreeNode{
Name: "root"
Value: nil
Children: {
{
Name: "branch #1"
Value: int(100)
Children: nil
}
{
Name: "branch #2"
Value: main.NodeValue{}
Children: nil
}
}
}