(size int64)
| 3 | import "fmt" |
| 4 | |
| 5 | func SizeToHumanReadable(size int64) string { |
| 6 | if size/1e9 > 0 { |
| 7 | return fmt.Sprintf("%.2f GigaBytes", float32(size)/1e9) |
| 8 | } else if size/1e6 > 0 { |
| 9 | return fmt.Sprintf("%.2f MegaBytes", float32(size)/1e6) |
| 10 | } else if size/1e3 > 0 { |
| 11 | return fmt.Sprintf("%.2f KiloBytes", float32(size)/1e3) |
| 12 | } |
| 13 | return fmt.Sprintf("%d Bytes", size) |
| 14 | } |
no outgoing calls