talira

Diff, fuzzy match and patch plain text in Go

open sourceMIT AND Apache-2.0free

go-diff is a Go port of Neil Fraser's google-diff-match-patch. Its diffmatchpatch package compares two texts and returns their differences (character- or line-level), finds a pattern in text by fuzzy matching, and creates and applies patches, the operations needed to keep plain text in sync. Its makers call it finished: bug fixes are released promptly and no new features are planned.

Problems it solves

  • show what changed between two versions of a text in my Go program
  • apply a text patch even when the target has drifted a little
  • sync edits to a plain-text document between clients in Go

Features

  • compare two texts and return their differences
  • line-level diffing
  • fuzzy matching of a pattern in text
  • create patches and apply them to text