textdiff is a lightweight and expressive Go library for comparing two texts and generating inline diffs in a Git-style format. It highlights added and removed words, making it ideal for applications like text editors, document review tools, and change tracking systems.
package main
import (
"fmt"
"textdiff/diff"
)
func main() {
a := "my name is John and I like apples"
b := "my name is Josh and I love oranges"
result := diff.CompareTexts(a, b)
fmt.Println(result)
}my name is [-John-] {+Josh+} and I [-like apples-] {+love oranges+}
Add the module to your Go project using:
go get github.com/laviodias/textdiff/diffRun tests with:
go test ./...MIT License. See the LICENSE file for details.
Contributions are welcome! Please open issues or pull requests for suggestions or improvements.
Documentation available at: