A simple diff library for Go.
Add go-diff to your project.
go get github.com/ktnyt/go-diff
package main
import (
"fmt"
"github.com/ktnt/go-diff"
)
func main() {
ops := diff.Diff("coelacanth", "pelican")
// Output: copelaicanth
fmt.Println(ops.Concat())
}
package main
import (
"fmt"
"github.com/ktnt/go-diff"
)
func main() {
ops := diff.LineDiff("foo\nbar\nbaz", "foo\nbaz\nbar")
// Output:
// | foo
// - bar
// | baz
// + bar
fmt.Println(ops.Join())
}