Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
func Diff(v1, v2 any)
Diff will pretty print two value and show side-by-side the difference between them.
Example ¶
package main import ( "github.com/adamluzsi/testcase/pp" ) type ExampleStruct struct { A string B int } func main() { pp.DiffFormat(ExampleStruct{ A: "The Answer", B: 42, }, ExampleStruct{ A: "The Question", B: 42, }) }
Output:
func DiffFormat ¶ added in v0.134.0
DiffFormat format the values in pp.Format and compare the results line by line in a side-by-side style.
Example ¶
package main import ( "fmt" "github.com/adamluzsi/testcase/pp" ) type ExampleStruct struct { A string B int } func main() { fmt.Println(pp.DiffFormat(ExampleStruct{ A: "The Answer", B: 42, }, ExampleStruct{ A: "The Question", B: 42, })) }
Output:
func DiffString ¶
DiffString compare strings line by line in a side-by-side style. The diff style is similar to GNU "diff -y".
Example ¶
package main import ( "github.com/adamluzsi/testcase/pp" ) func main() { _ = pp.DiffFormat("aaa\nbbb\nccc\n", "aaa\nccc\n") }
Output:
func Format ¶
Example ¶
package main import ( "github.com/adamluzsi/testcase/pp" ) type ExampleStruct struct { A string B int } func main() { _ = pp.Format(ExampleStruct{ A: "The Answer", B: 42, }) }
Output:
func PP ¶ added in v0.101.0
func PP(vs ...any)
Example (UnexportedFields) ¶
package main import ( "bytes" "encoding/json" "github.com/adamluzsi/testcase/pp" ) type ExampleStruct struct { A string B int } func main() { var buf bytes.Buffer bs, _ := json.Marshal(ExampleStruct{ A: "The Answer", B: 42, }) buf.Write(bs) pp.PP(buf) }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.