feat: docker compose backup
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package backup
|
||||
|
||||
import "fmt"
|
||||
|
||||
// FormatSize formats a byte count as a human-readable string.
|
||||
func FormatSize(n int64) string {
|
||||
const unit = 1024
|
||||
if n < unit {
|
||||
return fmt.Sprintf("%d B", n)
|
||||
}
|
||||
div, exp := int64(unit), 0
|
||||
for b := n / unit; b >= unit; b /= unit {
|
||||
div *= unit
|
||||
exp++
|
||||
}
|
||||
return fmt.Sprintf("%.1f %cB", float64(n)/float64(div), "KMGTPE"[exp])
|
||||
}
|
||||
Reference in New Issue
Block a user