From 99698737d96b74d5a1df9d3ce32a389a220d8bac Mon Sep 17 00:00:00 2001 From: Joel Watson Date: Tue, 10 Nov 2020 16:39:12 -0600 Subject: [PATCH] Check for nil rather than length --- command/snapshot/inspect/formatter.go | 2 +- command/snapshot/inspect/snapshot_inspect.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/command/snapshot/inspect/formatter.go b/command/snapshot/inspect/formatter.go index bd45501ab..c8c308b5f 100644 --- a/command/snapshot/inspect/formatter.go +++ b/command/snapshot/inspect/formatter.go @@ -57,7 +57,7 @@ func (_ *prettyFormatter) Format(info *OutputFormat) (string, error) { fmt.Fprintf(tw, "\n %s\t%s\t%s\t", "----", "----", "----") fmt.Fprintf(tw, "\n Total\t\t%s\t", ByteSize(uint64(info.TotalSize))) - if len(info.StatsKV) > 0 { + if info.StatsKV != nil { fmt.Fprintf(tw, "\n") fmt.Fprintln(tw, "\n Key Name\tCount\tSize\t") fmt.Fprintf(tw, " %s\t%s\t%s\t", "----", "----", "----") diff --git a/command/snapshot/inspect/snapshot_inspect.go b/command/snapshot/inspect/snapshot_inspect.go index 5c40c1c67..83216cc4d 100644 --- a/command/snapshot/inspect/snapshot_inspect.go +++ b/command/snapshot/inspect/snapshot_inspect.go @@ -199,7 +199,7 @@ func generateStats(info SnapshotInfo) []typeStats { } func generateKVStats(info SnapshotInfo) []typeStats { - if len(info.StatsKV) > 0 { + if info.StatsKV != nil { ks := make([]typeStats, 0, len(info.StatsKV)) for _, s := range info.StatsKV {