Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/sergi/go-diff
/ functions
Functions
144 in github.com/sergi/go-diff
⨍
Functions
144
◇
Types & classes
10
↓ 59 callers
Function
New
New creates a new DiffMatchPatch object with default parameters.
diffmatchpatch/diffmatchpatch.go:36
↓ 17 callers
Method
DiffMain
DiffMain finds the differences between two texts. The checklines flag is a speedup: if false, don't run a line-level diff first to identify the change
diffmatchpatch/diff.go:85
↓ 15 callers
Method
PatchMake
PatchMake computes a list of patches.
diffmatchpatch/patch.go:158
↓ 11 callers
Method
String
String emulates GNU diff's format. Header: @@ -382,8 +481,9 @@ Indices are printed as 1-based, not 0-based.
diffmatchpatch/patch.go:68
↓ 9 callers
Method
PatchApply
PatchApply merges a set of patches onto the text. Returns a patched text, as well as an array of true/false values indicating which patches were appl
diffmatchpatch/patch.go:285
↓ 8 callers
Function
speedtestTexts
()
diffmatchpatch/benchutil_test.go:17
↓ 7 callers
Method
DiffCharsToLines
DiffCharsToLines rehydrates the text in a diff from a string of line hashes to real lines of text.
diffmatchpatch/diff.go:408
↓ 7 callers
Method
DiffText1
DiffText1 computes and returns the source text (all equalities and deletions).
diffmatchpatch/diff.go:1197
↓ 6 callers
Method
PatchFromText
PatchFromText parses a textual representation of patches and returns a List of Patch objects.
diffmatchpatch/patch.go:592
↓ 6 callers
Method
PatchToText
PatchToText takes a list of patches and returns a textual representation.
diffmatchpatch/patch.go:581
↓ 6 callers
Function
commonPrefixLength
commonPrefixLength returns the length of the common prefix of two rune slices.
diffmatchpatch/diff.go:437
↓ 6 callers
Function
commonSuffixLength
commonSuffixLength returns the length of the common suffix of two rune slices.
diffmatchpatch/diff.go:449
↓ 5 callers
Method
DiffCleanupSemantic
DiffCleanupSemantic reduces the number of edits by eliminating semantically trivial equalities.
diffmatchpatch/diff.go:623
↓ 5 callers
Method
DiffText2
DiffText2 computes and returns the destination text (all equalities and insertions).
diffmatchpatch/diff.go:1210
↓ 5 callers
Function
alignRuneStart
alignRuneStart backs up byte index idx to the nearest UTF-8 rune start byte. idx <= 0 or idx >= len(s) is returned unchanged. Motivation: Google's re
diffmatchpatch/patch.go:37
↓ 5 callers
Function
splice
splice removes amount elements from slice at index index, replacing them with elements.
diffmatchpatch/diff.go:46
↓ 4 callers
Method
DiffCleanupMerge
DiffCleanupMerge reorders and merges like edit sections. Merge equalities. Any edit section can move as long as it doesn't cross an equality.
diffmatchpatch/diff.go:975
↓ 4 callers
Method
DiffLinesToChars
DiffLinesToChars splits two texts into a list of strings, and educes the texts to a string of hashes where each Unicode character represents one line.
diffmatchpatch/diff.go:395
↓ 4 callers
Method
PatchSplitMax
PatchSplitMax looks through the patches and breaks up any which are longer than the maximum limit of the match algorithm. Intended to be called only f
diffmatchpatch/patch.go:452
↓ 4 callers
Method
diffMainRunes
(text1, text2 []rune, checklines bool, deadline time.Time)
diffmatchpatch/diff.go:100
↓ 4 callers
Function
max
(x, y int)
diffmatchpatch/mathutil.go:18
↓ 4 callers
Function
min
(x, y int)
diffmatchpatch/mathutil.go:11
↓ 3 callers
Method
DiffCleanupSemanticLossless
DiffCleanupSemanticLossless looks for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word bo
diffmatchpatch/diff.go:791
↓ 3 callers
Method
DiffLinesToRunes
DiffLinesToRunes splits two texts into a list of runes. At most 1,112,060 unique lines can be encoded across both texts; if the texts contain more uni
diffmatchpatch/diff.go:402
↓ 3 callers
Method
DiffMainRunes
DiffMainRunes finds the differences between two rune sequences. The checklines flag is a speedup: if false, don't run a line-level diff first to ident
diffmatchpatch/diff.go:92
↓ 3 callers
Method
MatchBitap
MatchBitap locates the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm. Returns -1 if no match was found.
diffmatchpatch/match.go:37
↓ 3 callers
Method
MatchMain
MatchMain locates the best instance of 'pattern' in 'text' near 'loc'. Returns -1 if no match found.
diffmatchpatch/match.go:17
↓ 3 callers
Function
alignRuneEnd
alignRuneEnd moves byte index idx forward to the next UTF-8 rune start. idx <= 0 or idx >= len(s) is returned unchanged.
diffmatchpatch/patch.go:49
↓ 3 callers
Function
indexOf
indexOf returns the first index of pattern in str, starting at str[i].
diffmatchpatch/stringutil.go:32
↓ 3 callers
Function
indexesToString
(indexes []index)
diffmatchpatch/index.go:22
↓ 3 callers
Function
intToRune
Converts an integer in the range 0~1112060 into a rune. Based on the ranges table in https://en.wikipedia.org/wiki/UTF-8
diffmatchpatch/stringutil.go:122
↓ 2 callers
Method
DiffCleanupEfficiency
DiffCleanupEfficiency reduces the number of edits by eliminating operationally trivial equalities.
diffmatchpatch/diff.go:864
↓ 2 callers
Method
DiffCommonOverlap
DiffCommonOverlap determines if the suffix of one string is the prefix of another.
diffmatchpatch/diff.go:477
↓ 2 callers
Method
DiffCommonPrefix
DiffCommonPrefix determines the common prefix length of two strings.
diffmatchpatch/diff.go:425
↓ 2 callers
Method
DiffCommonSuffix
DiffCommonSuffix determines the common suffix length of two strings.
diffmatchpatch/diff.go:431
↓ 2 callers
Method
DiffHalfMatch
DiffHalfMatch checks whether the two texts share a substring which is at least half the length of the longer text. This speedup can produce non-minima
diffmatchpatch/diff.go:517
↓ 2 callers
Method
DiffLevenshtein
DiffLevenshtein computes the Levenshtein distance that is the number of inserted, deleted or substituted characters.
diffmatchpatch/diff.go:1222
↓ 2 callers
Method
DiffXIndex
DiffXIndex returns the equivalent location in s2.
diffmatchpatch/diff.go:1102
↓ 2 callers
Method
PatchAddContext
PatchAddContext increases the context until it is unique, but doesn't let the pattern expand beyond MatchMaxBits.
diffmatchpatch/patch.go:109
↓ 2 callers
Method
PatchAddPadding
PatchAddPadding adds some padding on text start and end so that edges can match something. Intended to be called only from within patchApply.
diffmatchpatch/patch.go:400
↓ 2 callers
Method
PatchDeepCopy
PatchDeepCopy returns an array that is identical to a given an array of patches.
diffmatchpatch/patch.go:265
↓ 2 callers
Method
diffBisect
diffBisect finds the 'middle snake' of a diff, splits the problem in two and returns the recursively constructed diff. See Myers's 1986 paper: An O(ND
diffmatchpatch/diff.go:263
↓ 2 callers
Method
diffBisectSplit
(runes1, runes2 []rune, x, y int, deadline time.Time)
diffmatchpatch/diff.go:378
↓ 2 callers
Function
diffCleanupSemanticScore
diffCleanupSemanticScore computes a score representing whether the internal boundary falls on logical boundaries. Scores range from 6 (best) to 0 (wor
diffmatchpatch/diff.go:749
↓ 2 callers
Method
diffHalfMatch
(text1, text2 []rune)
diffmatchpatch/diff.go:531
↓ 2 callers
Method
diffLinesToStrings
diffLinesToStrings splits two texts into a list of strings. Each string represents one line.
diffmatchpatch/diff.go:1339
↓ 2 callers
Function
diffText1Prefix
diffText1Prefix returns the first n bytes of DiffText1(diffs) without building the whole text. If byte n falls inside a multi-byte rune, the prefix st
diffmatchpatch/patch.go:557
↓ 2 callers
Function
lastIndexOf
lastIndexOf returns the last index of pattern in str, starting at str[i].
diffmatchpatch/stringutil.go:47
↓ 2 callers
Function
runeToInt
Converts a rune generated by intToRune back to an integer
diffmatchpatch/stringutil.go:161
↓ 2 callers
Function
runesEqual
(r1, r2 []rune)
diffmatchpatch/stringutil.go:73
↓ 2 callers
Function
runesIndex
runesIndex is the equivalent of strings.Index for rune slices.
diffmatchpatch/stringutil.go:86
↓ 2 callers
Function
runesIndexOf
runesIndexOf returns the index of pattern in target, starting at target[i].
diffmatchpatch/stringutil.go:59
↓ 1 callers
Method
DiffBisect
DiffBisect finds the 'middle snake' of a diff, split the problem in two and return the recursively constructed diff. If an invalid UTF-8 sequence is e
diffmatchpatch/diff.go:256
↓ 1 callers
Method
DiffFromDelta
DiffFromDelta given the original text1, and an encoded string which describes the operations required to transform text1 into text2, comAdde the full
diffmatchpatch/diff.go:1278
↓ 1 callers
Method
DiffPrettyHtml
DiffPrettyHtml converts a []Diff into a pretty HTML report. It is intended as an example from which to write one's own display functions.
diffmatchpatch/diff.go:1136
↓ 1 callers
Method
DiffPrettyText
DiffPrettyText converts a []Diff into a colored text report.
diffmatchpatch/diff.go:1159
↓ 1 callers
Method
DiffToDelta
DiffToDelta crushes the diff into an encoded string which describes the operations required to transform text1 into text2. E.g. =3\t-2\t+ing -> Keep
diffmatchpatch/diff.go:1247
↓ 1 callers
Method
MatchAlphabet
MatchAlphabet initialises the alphabet for the Bitap algorithm.
diffmatchpatch/match.go:143
↓ 1 callers
Function
commonSuffixBytes
commonSuffixBytes returns the length in bytes of the common suffix of two strings, never splitting a rune.
diffmatchpatch/diff.go:464
↓ 1 callers
Method
diffCompute
diffCompute finds the differences between two rune slices. Assumes that the texts do not have any common prefix or suffix.
diffmatchpatch/diff.go:135
↓ 1 callers
Method
diffHalfMatchI
diffHalfMatchI checks if a substring of shorttext exist within longtext such that the substring is at least half the length of longtext? Returns a sli
diffmatchpatch/diff.go:582
↓ 1 callers
Method
diffLineMode
diffLineMode does a quick line-level diff on both []runes, then rediff the parts for greater accuracy. This speedup can produce non-minimal diffs.
diffmatchpatch/diff.go:196
↓ 1 callers
Method
diffLinesToStringsMunge
diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []index.
diffmatchpatch/diff.go:1354
↓ 1 callers
Function
diffRebuildTexts
(diffs []Diff)
diffmatchpatch/diff_test.go:48
↓ 1 callers
Function
getBits
Helper for getting a sequence of bits from an integer.
diffmatchpatch/stringutil.go:116
↓ 1 callers
Function
intArrayToString
(ns []index)
diffmatchpatch/stringutil.go:96
↓ 1 callers
Method
matchBitapScore
matchBitapScore computes and returns the score for a match with e errors and x location.
diffmatchpatch/match.go:128
↓ 1 callers
Method
patchMake2
patchMake2 computes a list of patches to turn text1 into text2. text2 is not provided, diffs are the delta between text1 and text2.
diffmatchpatch/patch.go:184
↓ 1 callers
Function
stringToIndex
next invalid code point
diffmatchpatch/index.go:9
Function
BenchmarkCommonLength
(b *testing.B)
diffmatchpatch/diff_test.go:149
Function
BenchmarkDiffCleanupSemantic
(b *testing.B)
diffmatchpatch/diff_test.go:896
Function
BenchmarkDiffCommonPrefix
(b *testing.B)
diffmatchpatch/diff_test.go:85
Function
BenchmarkDiffCommonSuffix
exported sink var to avoid compiler optimizations in benchmarks
diffmatchpatch/diff_test.go:137
Function
BenchmarkDiffHalfMatch
(b *testing.B)
diffmatchpatch/diff_test.go:270
Function
BenchmarkDiffMain
(bench *testing.B)
diffmatchpatch/diff_test.go:1542
Function
BenchmarkDiffMainLarge
(b *testing.B)
diffmatchpatch/diff_test.go:1562
Function
BenchmarkDiffMainRunesLargeDiffLines
(b *testing.B)
diffmatchpatch/diff_test.go:1589
Function
BenchmarkDiffMainRunesLargeLines
(b *testing.B)
diffmatchpatch/diff_test.go:1574
Function
BenchmarkMatchBitap
(b *testing.B)
diffmatchpatch/match_test.go:176
Function
BenchmarkPatchApply
(b *testing.B)
diffmatchpatch/patch_test.go:407
Function
BenchmarkPatchFromText
(b *testing.B)
diffmatchpatch/patch_test.go:394
Function
BenchmarkPatchSplitMax
(b *testing.B)
diffmatchpatch/patch_test.go:422
Function
ExampleDiffMatchPatch_DiffCleanupSemantic
Cleanup shifts edits to word boundaries: the raw diff on the left splits words, the cleaned up diff on the right edits whole words.
diffmatchpatch/example_test.go:121
Function
ExampleDiffMatchPatch_DiffLinesToChars
Diff two texts line by line by reducing each line to a character, diffing the reduced texts and expanding the result back to lines.
diffmatchpatch/example_test.go:55
Function
ExampleDiffMatchPatch_DiffMain
Compare two texts and print the differences.
diffmatchpatch/example_test.go:19
Function
ExampleDiffMatchPatch_DiffText1
The diffs are plain data; the source and target texts can be reconstructed from them without any pretty printing.
diffmatchpatch/example_test.go:40
Function
ExampleDiffMatchPatch_MatchMain
Locate a pattern in the text, exactly or fuzzily.
diffmatchpatch/example_test.go:106
Function
ExampleDiffMatchPatch_PatchMake
Make a patch, convert it to text, and apply that text to the original later, possibly elsewhere.
diffmatchpatch/example_test.go:78
Method
String
()
diffmatchpatch/operation_string.go:11
Function
TestAlignRuneEnd
alignRuneEnd should move any byte index inside a multi-byte UTF-8 character forward to the start of the next character.
diffmatchpatch/patch_rune_safety_test.go:42
Function
TestAlignRuneStart
alignRuneStart should back any byte index inside a multi-byte UTF-8 character back to that character's first byte.
diffmatchpatch/patch_rune_safety_test.go:13
Function
TestCommonPrefixLength
(t *testing.T)
diffmatchpatch/diff_test.go:95
Function
TestCommonSuffixLength
(t *testing.T)
diffmatchpatch/diff_test.go:181
Function
TestDiffBisect
(t *testing.T)
diffmatchpatch/diff_test.go:1242
Function
TestDiffBisectSplit
(t *testing.T)
diffmatchpatch/diff_test.go:282
Function
TestDiffCharsToLines
(t *testing.T)
diffmatchpatch/diff_test.go:350
Function
TestDiffCleanupEfficiency
(t *testing.T)
diffmatchpatch/diff_test.go:910
Function
TestDiffCleanupMerge
(t *testing.T)
diffmatchpatch/diff_test.go:395
Function
TestDiffCleanupSemantic
(t *testing.T)
diffmatchpatch/diff_test.go:640
Function
TestDiffCleanupSemanticLossless
(t *testing.T)
diffmatchpatch/diff_test.go:490
next →
1–100 of 144, ranked by callers