diff options
| author | Bobby <[email protected]> | 2025-07-16 20:07:20 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2025-07-16 20:07:20 +0530 |
| commit | 2255bbed94e1459788203a92b5f0eec5370abcab (patch) | |
| tree | 36ec94fb7370235ca3f7e22f892a191b82650d47 /utils/format | |
| parent | bb54eaf6623acdcfb2e9056eb803260dff2150a5 (diff) | |
| download | imageboard-2255bbed94e1459788203a92b5f0eec5370abcab.tar.xz imageboard-2255bbed94e1459788203a92b5f0eec5370abcab.zip | |
upload ui for images; registered users can upload
Diffstat (limited to 'utils/format')
| -rw-r--r-- | utils/format/format.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/utils/format/format.go b/utils/format/format.go index 53c813e..e57bc1f 100644 --- a/utils/format/format.go +++ b/utils/format/format.go @@ -13,7 +13,12 @@ func FileSize(size int64) string { exp++ } - return fmt.Sprintf("%.2f %sB", float64(size)/float64(div), "KMGTPE"[exp:exp+1]) + val := float64(size) / float64(div) + unitStr := "KMGTPE"[exp : exp+1] + if val == float64(int64(val)) { + return fmt.Sprintf("%d %sB", int64(val), unitStr) + } + return fmt.Sprintf("%.2f %sB", val, unitStr) } func Count(count int64) string { |
