Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( // DefaultIndent is the default indent string used to indent nested values. DefaultIndent = " " // DefaultRecursionMarker is the default string to displayed when recursion is // detected within a Go value. DefaultRecursionMarker = "<recursion>" )
Variables ¶
This section is empty.
Functions ¶
func Format ¶
func Format(v interface{}) string
Format returns a pretty-printed representation of v.
Example ¶
type TreeNode struct {
Name string
Value interface{}
Children []*TreeNode
}
type NodeValue struct{}
v := TreeNode{
Name: "root",
Children: []*TreeNode{
{
Name: "branch #1",
Value: 100,
},
{
Name: "branch #2",
Value: NodeValue{},
},
},
}
s := Format(v)
fmt.Println(s)
Output: dapper_test.TreeNode{ Name: "root" Value: nil Children: { { Name: "branch #1" Value: int(100) Children: nil } { Name: "branch #2" Value: dapper_test.NodeValue{} Children: nil } } }
Types ¶
type Printer ¶
type Printer struct {
// Indent is the string used to indent nested values.
// If it is empty, DefaultIndent is used.
Indent string
// RecursionMarker is a string that is displayed instead of a value's
// representation when recursion has been detected.
// If it is empty, DefaultRecursionMarker is used.
RecursionMarker string
}
Printer generates human-readable representations of Go values.
The output format is intended to be as minimal as possible, without being ambigious. To that end, type information is only included where it can not be reliably inferred from the structure of the value.
Click to show internal directories.
Click to hide internal directories.