You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
multilinediff/multilinediff.go

22 lines
451 B
Go

package multilinediff
import (
"strings"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)
// Get the diff between two strings.
func Diff(a, b, lineSep string) (string, int) {
reporter := Reporter{LineSep: lineSep}
cmp.Diff(
a, b,
cmpopts.AcyclicTransformer("multiline", func(s string) []string {
return strings.Split(s, lineSep)
}),
cmp.Reporter(&reporter),
)
return reporter.String(), reporter.DiffCount
}