Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
func Diff[T any](v1, v2 T)
Diff will pretty print two value and show side-by-side the difference between them.
Example ¶
package main
import (
"go.llib.dev/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,
})
}
func DiffFormat ¶
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"
"go.llib.dev/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,
}))
}
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 (
"go.llib.dev/testcase/pp"
)
func main() {
_ = pp.DiffFormat("aaa\nbbb\nccc\n", "aaa\nccc\n")
}
func Format ¶
Example ¶
package main
import (
"go.llib.dev/testcase/pp"
)
type ExampleStruct struct {
A string
B int
}
func main() {
_ = pp.Format(ExampleStruct{
A: "The Answer",
B: 42,
})
}
func PP ¶
func PP(vs ...any)
Example (UnexportedFields) ¶
package main
import (
"bytes"
"encoding/json"
"go.llib.dev/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)
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.