ソースを参照

Gytes to Bytes

Signed-off-by: Vishal Rana <vishal.rana@verizon.com>
Vishal Rana 9 年 前
コミット
bfff5bf046
6 ファイル変更52 行追加52 行削除
  1. 1 1
      .travis.yml
  2. 1 1
      README.md
  3. 39 0
      bytes/README.md
  4. 9 9
      bytes/bytes.go
  5. 2 2
      bytes/bytes_test.go
  6. 0 39
      gytes/README.md

+ 1 - 1
.travis.yml

@@ -9,7 +9,7 @@ before_install:
 script:
     - go test -race ./...
     - go test -coverprofile=color.coverprofile ./color
-    - go test -coverprofile=gytes.coverprofile ./gytes
+    - go test -coverprofile=bytes.coverprofile ./bytes
     - go test -coverprofile=log.coverprofile ./log
     - $HOME/gopath/bin/gover
     - $HOME/gopath/bin/goveralls -coverprofile=gover.coverprofile -service=travis-ci

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 # Gommon [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/labstack/gommon) [![Build Status](http://img.shields.io/travis/labstack/gommon.svg?style=flat-square)](https://travis-ci.org/labstack/gommon) [![Coverage Status](http://img.shields.io/coveralls/labstack/gommon.svg?style=flat-square)](https://coveralls.io/r/labstack/gommon)
 
 Common packages for Go
-- [Gytes](https://github.com/labstack/gommon/tree/master/gytes) - Format bytes to string.
+- [Bytes](https://github.com/labstack/gommon/tree/master/bytes) - Format bytes to string.
 - [Color](https://github.com/labstack/gommon/tree/master/color) - Style terminal text.
 - [Log](https://github.com/labstack/gommon/tree/master/log) - Simple logging.

+ 39 - 0
bytes/README.md

@@ -0,0 +1,39 @@
+# Bytes
+
+Format bytes to string
+
+## Installation
+
+```go
+go get github.com/labstack/gommon/bytes
+```
+
+## [Usage](https://github.com/labstack/gommon/blob/master/bytes/bytes_test.go)
+
+```sh
+import github.com/labstack/gommon/bytes
+```
+
+### Decimal prefix
+
+```go
+fmt.Println(bytes.Format(1323))
+```
+
+`1.32 KB`
+
+### Binary prefix
+
+```go
+bytes.SetBinaryPrefix(true)
+fmt.Println(bytes.Format(1323))
+```
+
+`1.29 KiB`
+
+### New instance
+
+```go
+g := New()
+fmt.Println(g.Format(13231323))
+```

+ 9 - 9
gytes/gytes.go → bytes/bytes.go

@@ -1,4 +1,4 @@
-package gytes
+package bytes
 
 import (
 	"fmt"
@@ -11,24 +11,24 @@ var (
 )
 
 type (
-	Gytes struct {
+	Bytes struct {
 		iec bool
 	}
 )
 
-// New creates a Gytes instance.
-func New() *Gytes {
-	return &Gytes{}
+// New creates a Bytes instance.
+func New() *Bytes {
+	return &Bytes{}
 }
 
 // SetBinaryPrefix sets binary prefix format.
-func (g *Gytes) SetBinaryPrefix(on bool) {
+func (g *Bytes) SetBinaryPrefix(on bool) {
 	g.iec = on
 }
 
 // Format formats bytes to string. For example, 1323 bytes will return 1.32 KB.
 // If binary prefix is set, it will return 1.29 KiB.
-func (g *Gytes) Format(b uint64) string {
+func (g *Bytes) Format(b uint64) string {
 	unit := uint64(1000)
 	if g.iec {
 		unit = 1024
@@ -50,12 +50,12 @@ func (g *Gytes) Format(b uint64) string {
 
 }
 
-// BinaryPrefix wraps global Gytes's BinaryPrefix function.
+// BinaryPrefix wraps global Bytes's BinaryPrefix function.
 func BinaryPrefix(on bool) {
 	global.SetBinaryPrefix(on)
 }
 
-// Format wraps global Gytes's Format function.
+// Format wraps global Bytes's Format function.
 func Format(b uint64) string {
 	return global.Format(b)
 }

+ 2 - 2
gytes/gytes_test.go → bytes/bytes_test.go

@@ -1,8 +1,8 @@
-package gytes
+package bytes
 
 import "testing"
 
-func TestGytes(t *testing.T) {
+func TestBytes(t *testing.T) {
 	// B
 	b := Format(515)
 	if b != "515 B" {

+ 0 - 39
gytes/README.md

@@ -1,39 +0,0 @@
-# Gytes
-
-Format bytes to string
-
-## Installation
-
-```go
-go get github.com/labstack/gommon/gytes
-```
-
-## [Usage](https://github.com/labstack/gommon/blob/master/gytes/gytes_test.go)
-
-```sh
-import github.com/labstack/gommon/gytes
-```
-
-### Decimal prefix
-
-```go
-fmt.Println(gytes.Format(1323))
-```
-
-`1.32 KB`
-
-### Binary prefix
-
-```go
-gytes.SetBinaryPrefix(true)
-fmt.Println(gytes.Format(1323))
-```
-
-`1.29 KiB`
-
-### New instance
-
-```go
-g := New()
-fmt.Println(g.Format(13231323))
-```