Use fmt.Sprintf instead of manual string concatenation (#7)
diff --git a/cmp/path.go b/cmp/path.go
index d760d8d..5a88dbd 100644
--- a/cmp/path.go
+++ b/cmp/path.go
@@ -202,7 +202,7 @@
if s == "" || strings.ContainsAny(s, "{}\n") {
return "root" // Type too simple or complex to print
}
- return "{" + s + "}"
+ return fmt.Sprintf("{%s}", s)
}
func (si sliceIndex) String() string { return fmt.Sprintf("[%d]", si.key) }
diff --git a/cmp/reporter.go b/cmp/reporter.go
index 14e3d8b..1b812f5 100644
--- a/cmp/reporter.go
+++ b/cmp/reporter.go
@@ -171,7 +171,7 @@
s := formatAny(v.Index(i), subConf, visited)
ss = append(ss, s)
}
- s := "{" + strings.Join(ss, ", ") + "}"
+ s := fmt.Sprintf("{%s}", strings.Join(ss, ", "))
if conf.printType {
return v.Type().String() + s
}
@@ -196,7 +196,7 @@
sv := formatAny(v.MapIndex(k), subConf, visited)
ss = append(ss, fmt.Sprintf("%s: %s", sk, sv))
}
- s := "{" + strings.Join(ss, ", ") + "}"
+ s := fmt.Sprintf("{%s}", strings.Join(ss, ", "))
if conf.printType {
return v.Type().String() + s
}
@@ -215,7 +215,7 @@
s := formatAny(vv, subConf, visited)
ss = append(ss, fmt.Sprintf("%s: %s", name, s))
}
- s := "{" + strings.Join(ss, ", ") + "}"
+ s := fmt.Sprintf("{%s}", strings.Join(ss, ", "))
if conf.printType {
return v.Type().String() + s
}