Browse Source

Changed binary prefix function

Signed-off-by: Vishal Rana <vr@labstack.com>
Vishal Rana 10 years ago
parent
commit
1109e5b250
3 changed files with 8 additions and 7 deletions
  1. 1 1
      bytes/README.md
  2. 5 4
      bytes/bytes.go
  3. 2 2
      bytes/bytes_test.go

+ 1 - 1
bytes/README.md

@@ -19,7 +19,7 @@ fmt.Println(bytes.Format(1323))
 ### Binary prefix
 
 ```go
-fmt.Println(bytes.FormatBin(1323))
+fmt.Println(bytes.FormatB(1323))
 ```
 
 `1.29 KiB`

+ 5 - 4
bytes/bytes.go

@@ -6,14 +6,15 @@ import (
 	"math"
 )
 
-// Format formats bytes to string. For example, 1000 would returns 1 KB
+// Format formats bytes to string with decimal prefix. For example, 1000 would returns
+// 1 KB
 func Format(b uint64) string {
 	return format(float64(b), false)
 }
 
-// FormatBin formats bytes to string as specified by ICE standard. For example,
-// 1024 would return 1 KiB.
-func FormatBin(b uint64) string {
+// FormatB formats bytes to string with binary prefix. For example, 1024 would
+// return 1 KiB.
+func FormatB(b uint64) string {
 	return format(float64(b), true)
 }
 

+ 2 - 2
bytes/bytes_test.go

@@ -22,8 +22,8 @@ func TestFormat(t *testing.T) {
 	}
 }
 
-func TestFormatBin(t *testing.T) {
-	f := FormatBin(1323)
+func TestFormatB(t *testing.T) {
+	f := FormatB(1323)
 	if f != "1.29 KiB" {
 		t.Errorf("formatted bytes should be 1.29 KiB, found %s", f)
 	}