func hasWhitespaceDiffLines(groups [][]difflib.OpCode, a, b []string) bool {
	for _, group := range groups {
		in, out := new(bytes.Buffer), new(bytes.Buffer)
		for _, opCode := range group {
			if opCode.Tag == 'e' {
				continue
			}
			for _, line := range a[opCode.I1:opCode.I2] {
				in.WriteString(line)
			}
			for _, line := range b[opCode.J1:opCode.J2] {
				out.WriteString(line)
			}
		}
		if removeWhitespace(in.String()) == removeWhitespace(out.String()) {
			return true
		}
	}
	return false
}
hasWhitespaceDiffLines returns true if any diff groups is only different
because of whitespace characters.
package format
import (
	"bytes"
	"fmt"
	"strings"
	"unicode"
	"gotest.tools/v3/internal/difflib"
)
const (
	contextLines = 2
)
type DiffConfig struct {
	A    string
	B    string
	From string
	To   string
}
func UnifiedDiff(conf DiffConfig) string {
	a := strings.SplitAfter(conf.A, "\n")
	b := strings.SplitAfter(conf.B, "\n")
	groups := difflib.NewMatcher(a, b).GetGroupedOpCodes(contextLines)
	if len(groups) == 0 {
		return ""
	}
	buf := new(bytes.Buffer)
	writeFormat := func(format string, args ...interface{}) {
		buf.WriteString(fmt.Sprintf(format, args...))
	}
	writeLine := func(prefix string, s string) {
		buf.WriteString(prefix + s)
	}
	if hasWhitespaceDiffLines(groups, a, b) {
		writeLine = visibleWhitespaceLine(writeLine)
	}
	formatHeader(writeFormat, conf)
	for _, group := range groups {
		formatRangeLine(writeFormat, group)
		for _, opCode := range group {
			in, out := a[opCode.I1:opCode.I2], b[opCode.J1:opCode.J2]
			switch opCode.Tag {
			case 'e':
				formatLines(writeLine, " ", in)
			case 'r':
				formatLines(writeLine, "-", in)
				formatLines(writeLine, "+", out)
			case 'd':
				formatLines(writeLine, "-", in)
			case 'i':
				formatLines(writeLine, "+", out)
			}
		}
	}
	return buf.String()
}