-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReadme
More file actions
41 lines (30 loc) · 683 Bytes
/
Readme
File metadata and controls
41 lines (30 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package pretty
import "github.com/kr/pretty"
Package pretty provides pretty-printing for Go values.
Documentation
http://godoc.org/github.com/kr/pretty
Example:
```
package main
import (
"bytes"
"fmt"
"github.com/JekaMas/pretty"
)
func logDiff(obtained, expected interface{}) {
var failMessage bytes.Buffer
diffs := pretty.Diff(obtained, expected)
if len(diffs) > 0 {
failMessage.WriteString("Obtained:\t\tExpected:")
for _, singleDiff := range diffs {
failMessage.WriteString(fmt.Sprintf("\n%v", singleDiff))
}
}
fmt.Printf("... %s", failMessage.String())
}
func main() {
v1 := []int{0, 1, 2, 3}
v2 := []int{0, 1, 4}
logDiff(v1, v2)
}
```