Length check is required here

If one isn't included, then the nil check in the formatter never fails due to an empty slice being passed in, which causes the kv output to always get printed.
This commit is contained in:
Joel Watson 2020-11-11 10:44:55 -06:00
parent 5b4c8571d2
commit 0d48559416
1 changed files with 3 additions and 2 deletions

View File

@ -189,8 +189,9 @@ func generateStats(info SnapshotInfo) []typeStats {
// Generate the KV stats for the output struct that's
// used to produce the printed output the user sees.
func generateKVStats(info SnapshotInfo) []typeStats {
if info.StatsKV != nil {
ks := make([]typeStats, 0, len(info.StatsKV))
kvLen := len(info.StatsKV)
if kvLen > 0 {
ks := make([]typeStats, 0, kvLen)
for _, s := range info.StatsKV {
ks = append(ks, s)