aboutsummaryrefslogtreecommitdiff
path: root/cmp
diff options
context:
space:
mode:
authorFiisio <liangcszzu@163.com>2017-07-15 04:38:38 +0800
committerJoe Tsai <joetsai@digital-static.net>2017-07-14 14:38:38 -0600
commitd138b1d10e6659a13f00fe42bd26b8c8fe09f344 (patch)
tree53d65e1ae927fd129c554b8599275c60e509a929 /cmp
parent788cdcbba1690b498795e6c8f59c4b3c6be7264f (diff)
downloadgo-cmp-d138b1d10e6659a13f00fe42bd26b8c8fe09f344.tar.gz
Use fmt.Sprintf instead of manual string concatenation (#7)
Diffstat (limited to 'cmp')
-rw-r--r--cmp/path.go2
-rw-r--r--cmp/reporter.go6
2 files changed, 4 insertions, 4 deletions
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 @@ func (ps pathStep) String() string {
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 @@ func formatAny(v reflect.Value, conf formatConfig, visited map[uintptr]bool) str
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 @@ func formatAny(v reflect.Value, conf formatConfig, visited map[uintptr]bool) str
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 @@ func formatAny(v reflect.Value, conf formatConfig, visited map[uintptr]bool) str
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
}