const DefaultContextLines … // Unified returns a unified diff of the old and new strings. // The old and new labels are the names of the old and new files. // If the strings are equal, it returns the empty string. func Unified(oldLabel, newLabel, old, new string) string { … } // ToUnified applies the edits to content and returns a unified diff, // with contextLines lines of (unchanged) context around each diff hunk. // The old and new labels are the names of the content and result files. // It returns an error if the edits are inconsistent; see ApplyEdits. func ToUnified(oldLabel, newLabel, content string, edits []Edit, contextLines int) (string, error) { … } type unified … type hunk … type line … type opKind … const opDelete … const opInsert … const opEqual … // String returns a human readable representation of an OpKind. It is not // intended for machine processing. func (k opKind) String() string { … } // toUnified takes a file contents and a sequence of edits, and calculates // a unified diff that represents those edits. func toUnified(fromName, toName string, content string, edits []Edit, contextLines int) (unified, error) { … } func splitLines(text string) []string { … } func addEqualLines(h *hunk, lines []string, start, end int) int { … } // String converts a unified diff to the standard textual form for that diff. // The output of this function can be passed to tools like patch. func (u unified) String() string { … }