diff --git a/opts/opts.go b/opts/opts.go index c7d6c291bb..3ae0fdb6b9 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -409,7 +409,13 @@ type MemBytes int64 // String returns the string format of the human readable memory bytes func (m *MemBytes) String() string { - return units.BytesSize(float64(m.Value())) + // NOTE: In spf13/pflag/flag.go, "0" is considered as "zero value" while "0 B" is not. + // We return "0" in case value is 0 here so that the default value is hidden. + // (Sometimes "default 0 B" is actually misleading) + if m.Value() != 0 { + return units.BytesSize(float64(m.Value())) + } + return "0" } // Set sets the value of the MemBytes by passing a string