summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGokcehan <gokcehankara@gmail.com>2017-01-08 19:24:28 +0300
committerGokcehan <gokcehankara@gmail.com>2017-01-08 19:24:28 +0300
commit90e3a22dc880cde88335479911f6319ae86e2b8e (patch)
tree20091eb44e649d5a690e98e55ad401b6d46d9fbf
parent7c800cc373e0cc56be69a05a9cd80e870d6d1ff5 (diff)
add a 'B' suffix to files under a thousand bytes
Mentioned in #49.
-rw-r--r--misc.go2
-rw-r--r--misc_test.go8
2 files changed, 5 insertions, 5 deletions
diff --git a/misc.go b/misc.go
index 4c85cba..20b822c 100644
--- a/misc.go
+++ b/misc.go
@@ -140,7 +140,7 @@ func splitWord(s string) (word, rest string) {
// smaller values but it should be fine for most human beings.
func humanize(size int64) string {
if size < 1000 {
- return fmt.Sprintf("%d", size)
+ return fmt.Sprintf("%dB", size)
}
suffix := []string{
diff --git a/misc_test.go b/misc_test.go
index 3ab27b1..72881b8 100644
--- a/misc_test.go
+++ b/misc_test.go
@@ -157,10 +157,10 @@ func TestHumanize(t *testing.T) {
i int64
exp string
}{
- {0, "0"},
- {9, "9"},
- {99, "99"},
- {999, "999"},
+ {0, "0B"},
+ {9, "9B"},
+ {99, "99B"},
+ {999, "999B"},
{1000, "1.0K"},
{1023, "1.0K"},
{1025, "1.0K"},