convertFileSize() now returns only a concatination of a converted size and a size unit.
This commit is contained in:
parent
a567a27c69
commit
0798ba6602
@ -8,8 +8,8 @@ import (
|
||||
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) {
|
||||
// Returns a concatenation of a converted size and a unit
|
||||
func convertFileSize(size int64) string {
|
||||
var idx int
|
||||
var fSize float64 = float64(size)
|
||||
for idx = 0; fSize >= 1024; fSize /= 1024 {
|
||||
@ -18,5 +18,5 @@ func convertFileSize(size int64) (float64, string, string) {
|
||||
fSizeStr := strconv.FormatFloat(fSize, 'f', 3, 64)
|
||||
fSizeStr = strings.TrimRight(fSizeStr, "0")
|
||||
fSizeStr = strings.TrimSuffix(fSizeStr, ".")
|
||||
return fSize, sizeSuffixes[idx], fSizeStr + " " + sizeSuffixes[idx]
|
||||
return fSizeStr + " " + sizeSuffixes[idx]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user