Move ObjectDiff into util

This commit is contained in:
Clayton Coleman
2014-10-09 17:23:43 -04:00
parent 996c0e44d6
commit 935e97d59d
5 changed files with 71 additions and 52 deletions

View File

@@ -144,26 +144,6 @@ func (intstr IntOrString) MarshalJSON() ([]byte, error) {
}
}
// StringDiff diffs a and b and returns a human readable diff.
func StringDiff(a, b string) string {
ba := []byte(a)
bb := []byte(b)
out := []byte{}
i := 0
for ; i < len(ba) && i < len(bb); i++ {
if ba[i] != bb[i] {
break
}
out = append(out, ba[i])
}
out = append(out, []byte("\n\nA: ")...)
out = append(out, ba[i:]...)
out = append(out, []byte("\n\nB: ")...)
out = append(out, bb[i:]...)
out = append(out, []byte("\n\n")...)
return string(out)
}
// Takes a list of strings and compiles them into a list of regular expressions
func CompileRegexps(regexpStrings []string) ([]*regexp.Regexp, error) {
regexps := []*regexp.Regexp{}