add Diff util method

This commit is contained in:
Murat Kabilov 2017-09-26 13:13:15 +02:00
parent c67f06956e
commit c44cfff988
1 changed files with 7 additions and 3 deletions

View File

@ -52,10 +52,14 @@ func PGUserPassword(user spec.PgUser) string {
return md5prefix + hex.EncodeToString(s[:])
}
// Diff returns diffs between 2 objects
func Diff(a, b interface{}) []string {
return pretty.Diff(a, b)
}
// PrettyDiff shows the diff between 2 objects in an easy to understand format. It is mainly used for debugging output.
func PrettyDiff(a, b interface{}) (result string) {
diff := pretty.Diff(a, b)
return strings.Join(diff, "\n")
func PrettyDiff(a, b interface{}) string {
return strings.Join(Diff(a, b), "\n")
}
// SubstractStringSlices finds elements in a that are not in b and return them as a result slice.