mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-29 19:24:26 +03:00
26 lines
464 B
Go
26 lines
464 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
udiff "github.com/neilotoole/sq/cli/diff/internal/go-udiff"
|
|
)
|
|
|
|
func main() {
|
|
a := "Hello, world!\n"
|
|
b := "Hello, Go!\nSay hi to µDiff"
|
|
|
|
edits := udiff.Strings(a, b)
|
|
d, err := udiff.ToUnifiedDiff("a.txt", "b.txt", a, edits, 3)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
for _, h := range d.Hunks {
|
|
fmt.Printf("hunk: -%d, +%d\n", h.FromLine, h.ToLine)
|
|
for _, l := range h.Lines {
|
|
fmt.Printf("%s %q\n", l.Kind, l.Content)
|
|
}
|
|
}
|
|
}
|