gytes

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2015 License: MIT Imports: 3 Imported by: 0

README

Gytes

Format bytes to string

Installation

go get github.com/labstack/gommon/gytes

Usage

import github.com/labstack/gommon/gytes
Decimal prefix
fmt.Println(gytes.Format(1323))

1.32 KB

Binary prefix
gytes.BinaryPrefix(true)
fmt.Println(gytes.Format(1323))

1.29 KiB

New intance
Decimal prefix
g := New()
fmt.Println(g.Format(13231323))

13.23 MB

Binary prefix
g := New()
g.BinaryPrefix(true)
fmt.Println(g.Format(13231323))

12.62 MiB

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryPrefix

func BinaryPrefix(on bool)

BinaryPrefix wraps default instance's BinaryPrefix function.

func Format

func Format(b uint64) string

Format wraps default instance's Format function.

Types

type Gytes

type Gytes struct {
	// contains filtered or unexported fields
}

func New

func New() *Gytes

func (*Gytes) BinaryPrefix

func (g *Gytes) BinaryPrefix(on bool)

BinaryPrefix turns on binary prefix format.

func (*Gytes) Format

func (g *Gytes) Format(b uint64) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL