package bytes
import "github.com/labstack/gommon/bytes"
Index ¶
- Constants
- func Format(value int64) string
- func FormatBinary(value int64) string
- func FormatDecimal(value int64) string
- func Parse(value string) (int64, error)
- type Bytes
- func New() *Bytes
- func (b *Bytes) Format(value int64) string
- func (*Bytes) FormatBinary(value int64) string
- func (*Bytes) FormatDecimal(value int64) string
- func (b *Bytes) Parse(value string) (int64, error)
- func (*Bytes) ParseBinary(value string) (i int64, err error)
- func (*Bytes) ParseDecimal(value string) (i int64, err error)
Constants ¶
const ( KiB MiB GiB TiB PiB EiB )
binary units (IEC 60027)
const ( KB = 1000 MB = KB * 1000 GB = MB * 1000 TB = GB * 1000 PB = TB * 1000 EB = PB * 1000 )
decimal units (SI international system of units)
Functions ¶
func Format ¶
Format wraps global Bytes's Format function.
func FormatBinary ¶
FormatBinary wraps global Bytes's FormatBinary function.
func FormatDecimal ¶
FormatDecimal wraps global Bytes's FormatDecimal function.
func Parse ¶
Parse wraps global Bytes's Parse function.
Types ¶
type Bytes ¶
type Bytes struct{}
Bytes struct
func New ¶
func New() *Bytes
New creates a Bytes instance.
func (*Bytes) Format ¶
Format formats bytes integer to human readable string according to IEC 60027. For example, 31323 bytes will return 30.59KB.
func (*Bytes) FormatBinary ¶
FormatBinary formats bytes integer to human readable string according to IEC 60027. For example, 31323 bytes will return 30.59KB.
func (*Bytes) FormatDecimal ¶
FormatDecimal formats bytes integer to human readable string according to SI international system of units. For example, 31323 bytes will return 31.32KB.
func (*Bytes) Parse ¶
Parse parses human readable bytes string to bytes integer. For example, 6GiB (6Gi is also valid) will return 6442450944, and 6GB (6G is also valid) will return 6000000000.
func (*Bytes) ParseBinary ¶
ParseBinary parses human readable bytes string to bytes integer. For example, 6GiB (6Gi is also valid) will return 6442450944.
func (*Bytes) ParseDecimal ¶
ParseDecimal parses human readable bytes string to bytes integer. For example, 6GB (6G is also valid) will return 6000000000.
Source Files ¶
- Version
- v0.4.2 (latest)
- Published
- Dec 20, 2023
- Platform
- windows/amd64
- Imports
- 4 packages
- Last checked
- 1 hour ago –
Tools for package owners.