diff --git a/pkg/utils/filesize.go b/pkg/utils/filesize.go index be9f553..4df7460 100644 --- a/pkg/utils/filesize.go +++ b/pkg/utils/filesize.go @@ -1,8 +1,7 @@ package utils import ( - "io/fs" - "path/filepath" + "io/ioutil" "strconv" "strings" @@ -14,10 +13,10 @@ var sizeSuffixes = [...]string{"B", "KiB", "MiB", "GiB", "TiB"} // ConvertFileSize converts size in bytes down to biggest units it represents. // Returns converted size, unit and, a concatenation of size and unit func ConvertFileSize(size int64) (float64, string, string) { - var idx int - var fSize float64 = float64(size) + idx := 0 + fSize := float64(size) - for idx = 0; fSize >= 1024; fSize /= 1024 { + for ; fSize >= 1024; fSize /= 1024 { idx++ } @@ -25,7 +24,8 @@ func ConvertFileSize(size int64) (float64, string, string) { fSizeStr = strings.TrimRight(fSizeStr, "0") fSizeStr = strings.TrimSuffix(fSizeStr, ".") - return fSize, sizeSuffixes[idx], strings.Join([]string{fSizeStr, sizeSuffixes[idx]}, " ") + return fSize, sizeSuffixes[idx], + strings.Join([]string{fSizeStr, sizeSuffixes[idx]}, " ") } func DirectorySize(path string) (dirSz int64, err error) {