type Diff … // DiffStrings returns the differences between two strings. // It does not respect rune boundaries. func DiffStrings(a, b string) []Diff { … } // DiffBytes returns the differences between two byte sequences. // It does not respect rune boundaries. func DiffBytes(a, b []byte) []Diff { … } // DiffRunes returns the differences between two rune sequences. func DiffRunes(a, b []rune) []Diff { … } func diff(seqs sequences) []Diff { … } // compute computes the list of differences between two sequences, // along with the LCS. It is exercised directly by tests. // The algorithm is one of {forward, backward, twosided}. func compute(seqs sequences, algo func(*editGraph) lcs, limit int) ([]Diff, lcs) { … } type editGraph … // toDiffs converts an LCS to a list of edits. func (lcs lcs) toDiffs(alen, blen int) []Diff { … } // fdone decides if the forward path has reached the upper right // corner of the rectangle. If so, it also returns the computed lcs. func (e *editGraph) fdone(D, k int) (bool, lcs) { … } // run the forward algorithm, until success or up to the limit on D. func forward(e *editGraph) lcs { … } // recover the lcs by backtracking from the farthest point reached func (e *editGraph) forwardlcs(D, k int) lcs { … } // start at (x,y), go up the diagonal as far as possible, // and label the result with d func (e *editGraph) lookForward(k, relx int) int { … } func (e *editGraph) setForward(d, k, relx int) { … } func (e *editGraph) getForward(d, k int) int { … } // bdone decides if the backward path has reached the lower left corner func (e *editGraph) bdone(D, k int) (bool, lcs) { … } // run the backward algorithm, until success or up to the limit on D. func backward(e *editGraph) lcs { … } // recover the lcs by backtracking func (e *editGraph) backwardlcs(D, k int) lcs { … } // start at (x,y), go down the diagonal as far as possible, func (e *editGraph) lookBackward(k, relx int) int { … } // convert to rectangle, and label the result with d func (e *editGraph) setBackward(d, k, relx int) { … } func (e *editGraph) getBackward(d, k int) int { … } func twosided(e *editGraph) lcs { … } // Does Myers' Lemma apply? func (e *editGraph) twoDone(df, db int) (int, bool) { … } func (e *editGraph) twolcs(df, db, kf int) lcs { … }