-
Notifications
You must be signed in to change notification settings - Fork 2
/
diff_types.go
42 lines (35 loc) · 874 Bytes
/
diff_types.go
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
42
package diff
import "fmt"
// Delta represents the differential value passed to ResultFunc: NEW/OLD
type Delta int
const (
// NEW is an enum for a new/added value in a diff passed to ResultFunc
NEW = iota // +
// OLD is an enum for a removed value in a diff passed to ResultFunc
OLD // -
)
// StringResultFunc defines the interface for a function to
// be called for each delta record
type StringResultFunc func(Delta, string) error
func (d Delta) String() string {
switch d {
case NEW:
return ">"
case OLD:
return "<"
default:
return "?"
}
}
// Result stores statistics generated from diffing two streams
type Result struct {
ExtraA uint64
ExtraB uint64
TotalA uint64
TotalB uint64
Common uint64
}
func (r *Result) String() string {
out := fmt.Sprintf("A: %d/%d\tB: %d/%d\tC: %d", r.ExtraA, r.TotalA, r.ExtraB, r.TotalB, r.Common)
return out
}