diff --git a/convert/bytes_iec.go b/convert/bytes_iec.go index 478c2ae..5f69fcf 100644 --- a/convert/bytes_iec.go +++ b/convert/bytes_iec.go @@ -22,9 +22,8 @@ const IECBase = 1024 func (b BytesIEC) HumanReadable() string { value, unit := humanReadable(uint64(b), ByteIECUnits, IECBase) - s := strconv.FormatFloat(value, 'f', 2, 64) // nolint:gomnd - s = strings.TrimRight(s, "0") // Remove trailing zero decimals - s = strings.TrimRight(s, ".") // Remove any left over decimal dot + // Remove trailing zero decimals and any left over decimal dot + s := strings.TrimRight(strings.TrimRight(strconv.FormatFloat(value, 'f', 2, 64), "0"), ".") return s + unit } diff --git a/convert/bytes_si.go b/convert/bytes_si.go index 10646b9..eb29010 100644 --- a/convert/bytes_si.go +++ b/convert/bytes_si.go @@ -22,9 +22,8 @@ const SIBase = 1000 func (b BytesSI) HumanReadable() string { value, unit := humanReadable(uint64(b), ByteSIUnits, SIBase) - s := strconv.FormatFloat(value, 'f', 2, 64) // nolint:gomnd - s = strings.TrimRight(s, "0") // Remove trailing zero decimals - s = strings.TrimRight(s, ".") // Remove any left over decimal dot + // Remove trailing zero decimals and any left over decimal dot + s := strings.TrimRight(strings.TrimRight(strconv.FormatFloat(value, 'f', 2, 64), "0"), ".") return s + unit }