modulepackage
0.0.0-20131118162322-d8d9a906c24d
Repository: https://github.com/mb0/diff.git
Documentation: pkg.go.dev
# README
diff
A difference algorithm package for go.
The algorithm is described by Eugene Myers in "An O(ND) Difference Algorithm and its Variations".
Example
You can use diff.Ints, diff.Runes, diff.ByteStrings, and diff.Bytes
diff.Runes([]rune("sögen"), []rune("mögen")) // returns []Changes{{0,0,1,1}}
or you can implement diff.Data
type MixedInput struct {
A []int
B []string
}
func (m *MixedInput) Equal(i, j int) bool {
return m.A[i] == len(m.B[j])
}
and call
m := &MixedInput{..}
diff.Diff(len(m.A), len(m.B), m)
Also has granularity functions to merge changes that are close by.
diff.Granular(1, diff.ByteStrings("emtire", "umpire")) // returns []Changes{{0,0,3,3}}
Documentation at http://godoc.org/github.com/mb0/diff
# Functions
Bytes returns the difference of two byte slices.
ByteStrings returns the differences of two strings in bytes.
Diff returns the differences of data.
Granular merges neighboring changes smaller than the specified granularity.
Ints returns the difference of two int slices.
Runes returns the difference of two rune slices.
# Structs
A Change contains one or more deletions or inserts at one position in two sequences.
# Interfaces
A type that satisfies diff.Data can be diffed by this package.