size

package module
v0.0.0-...-40ea84d Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MIT Imports: 3 Imported by: 0

README

Size

Build Status

Package size is a simple package to handle memory or disk size calculation or format

Installation

go get github.com/lunny/size

Usage

import (
    "fmt"

    . "github.com/lunny/size"
)

func main() {
    fmt.Println(10*M)

    size, _ := ParseSize("1.2K")
    fmt.Println(size)
}

Documentation

Index

Constants

View Source
const (
	B = Size(1)
	K = 1024 * B
	M = 1024 * K
	G = 1024 * M
	T = 1024 * G
	P = 1024 * T
)

all possible size

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrSizeFormat

type ErrSizeFormat string

ErrSizeFormat defines an error when format is not corrected

func (ErrSizeFormat) Error

func (e ErrSizeFormat) Error() string

Error implements error interface

type Size

type Size float64

Size represents a size type

func ParseSize

func ParseSize(layout string) (Size, error)

ParseSize parses the layout to size

func (Size) String

func (s Size) String() string

String shows the size's format layout

Jump to

Keyboard shortcuts

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