2020-09-23 15:49:59 -04:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2020-09-30 01:11:33 -04:00
|
|
|
package print
|
2020-09-23 15:49:59 -04:00
|
|
|
|
2020-09-30 01:11:33 -04:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// formatSize get kb in int and return string
|
|
|
|
func formatSize(kb int64) string {
|
2020-09-23 15:49:59 -04:00
|
|
|
if kb < 1024 {
|
|
|
|
return fmt.Sprintf("%d Kb", kb)
|
|
|
|
}
|
|
|
|
mb := kb / 1024
|
|
|
|
if mb < 1024 {
|
|
|
|
return fmt.Sprintf("%d Mb", mb)
|
|
|
|
}
|
|
|
|
gb := mb / 1024
|
|
|
|
if gb < 1024 {
|
|
|
|
return fmt.Sprintf("%d Gb", gb)
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("%d Tb", gb/1024)
|
|
|
|
}
|