ran gofmt
diff --git a/diffmatchpatch/dmp.go b/diffmatchpatch/dmp.go
index 70f3954..8cd26c3 100644
--- a/diffmatchpatch/dmp.go
+++ b/diffmatchpatch/dmp.go
@@ -93,7 +93,7 @@
// Return the index of pattern in target, starting at target[i].
func runesIndexOf(target, pattern []rune, i int) int {
- if i > len(target) - 1 {
+ if i > len(target)-1 {
return -1
}
ind := runesIndex(target[i:], pattern)
@@ -260,7 +260,6 @@
return dmp.diffMainRunes(text1, text2, checklines, deadline)
}
-
func (dmp *DiffMatchPatch) diffMainRunes(text1, text2 []rune, checklines bool, deadline time.Time) []Diff {
if runesEqual(text1, text2) {
var diffs []Diff
@@ -295,7 +294,6 @@
return dmp.DiffCleanupMerge(diffs)
}
-
// diffCompute finds the differences between two rune slices. Assumes that the texts do not
// have any common prefix or suffix.
func (dmp *DiffMatchPatch) diffCompute(text1, text2 []rune, checklines bool, deadline time.Time) []Diff {
@@ -412,7 +410,6 @@
return diffs[:len(diffs)-1] // Remove the dummy entry at the end.
}
-
// DiffBisect finds the 'middle snake' of a diff, split the problem in two
// and return the recursively constructed diff.
// See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
@@ -471,7 +468,7 @@
y1 := x1 - k1
for x1 < text1_len && y1 < text2_len {
if text1[x1] != text2[y1] {
- break
+ break
}
x1++
y1++
@@ -658,7 +655,7 @@
}
return len(short)
}
-
+
// commonSuffixLength returns the length of the common suffix of two rune slices.
func commonSuffixLength(text1, text2 []rune) int {
n := min(len(text1), len(text2))
@@ -688,8 +685,7 @@
}
return pointermid
*/
-}
-
+}
// DiffCommonOverlap determines if the suffix of one string is the prefix of another.
func (dmp *DiffMatchPatch) DiffCommonOverlap(text1 string, text2 string) int {
@@ -748,7 +744,7 @@
return result
}
-func(dmp *DiffMatchPatch) diffHalfMatch(text1, text2 []rune) [][]rune {
+func (dmp *DiffMatchPatch) diffHalfMatch(text1, text2 []rune) [][]rune {
if dmp.DiffTimeout <= 0 {
// Don't risk returning a non-optimal diff if we have unlimited time.
return nil
@@ -853,7 +849,7 @@
}
func concat(r1, r2 []rune) []rune {
- result := make([]rune, len(r1) + len(r2))
+ result := make([]rune, len(r1)+len(r2))
copy(result, r1)
copy(result[len(r1):], r2)
return result
diff --git a/diffmatchpatch/dmp_test.go b/diffmatchpatch/dmp_test.go
index a6e4031..086e5df 100644
--- a/diffmatchpatch/dmp_test.go
+++ b/diffmatchpatch/dmp_test.go
@@ -127,10 +127,10 @@
}
func Test_commonPrefixLength(t *testing.T) {
- for _, test := range []struct{
+ for _, test := range []struct {
s1, s2 string
- want int
- } {
+ want int
+ }{
{"abc", "xyz", 0},
{"1234abcdef", "1234xyz", 4},
{"1234", "1234xyz", 4},
@@ -154,10 +154,10 @@
}
func Test_commonSuffixLength(t *testing.T) {
- for _, test := range []struct{
+ for _, test := range []struct {
s1, s2 string
- want int
- } {
+ want int
+ }{
{"abc", "xyz", 0},
{"abcdef1234", "xyz1234", 4},
{"1234", "xyz1234", 4},
@@ -170,11 +170,11 @@
func Test_runesIndexOf(t *testing.T) {
target := []rune("abcde")
- for _, test := range []struct{
+ for _, test := range []struct {
pattern string
- start int
- want int
- } {
+ start int
+ want int
+ }{
{"abc", 0, 0},
{"cde", 0, 2},
{"e", 0, 4},
@@ -193,7 +193,6 @@
}
}
-
func Test_diffCommonOverlapTest(t *testing.T) {
dmp := New()
// Detect any suffix/prefix overlap.
@@ -219,8 +218,8 @@
dmp := New()
dmp.DiffTimeout = 1
// No match.
- assert.True(t, dmp.DiffHalfMatch("1234567890", "abcdef") == nil, "")
- assert.True(t, dmp.DiffHalfMatch("12345", "23") == nil, "")
+ assert.True(t, dmp.DiffHalfMatch("1234567890", "abcdef") == nil, "")
+ assert.True(t, dmp.DiffHalfMatch("12345", "23") == nil, "")
// Single Match.
assertStrEqual(t,
@@ -329,7 +328,7 @@
charList := []rune{}
for x := 1; x <= n; x++ {
- lineList = append(lineList, strconv.Itoa(x) + "\n")
+ lineList = append(lineList, strconv.Itoa(x)+"\n")
charList = append(charList, rune(x))
}
@@ -477,8 +476,8 @@
diffs = dmp.DiffCleanupSemanticLossless(diffs)
assertDiffEqual(t, []Diff{
- Diff{DiffDelete, "a"},
- Diff{DiffEqual, "aax"}}, diffs)
+ Diff{DiffDelete, "a"},
+ Diff{DiffEqual, "aax"}}, diffs)
// Hitting the end.
diffs = []Diff{
@@ -801,13 +800,13 @@
// Generates error (%xy invalid URL escape).
_, err = dmp.DiffFromDelta("", "+%c3%xy")
if err == nil {
- assert.Fail(t, "diff_fromDelta: expected Invalid URL escape.");
+ assert.Fail(t, "diff_fromDelta: expected Invalid URL escape.")
}
// Generates error (invalid utf8).
_, err = dmp.DiffFromDelta("", "+%c3xy")
if err == nil {
- assert.Fail(t, "diff_fromDelta: expected Invalid utf8.");
+ assert.Fail(t, "diff_fromDelta: expected Invalid utf8.")
}
// Test deltas with special characters.
@@ -1447,4 +1446,3 @@
}
return string(bytes)
}
-
\ No newline at end of file