README ¶ Size 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) } Expand ▾ Collapse ▴ Documentation ¶ Index ¶ Constants type ErrSizeFormat func (e ErrSizeFormat) Error() string type Size func ParseSize(layout string) (Size, error) func (s Size) String() string 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 Source Files ¶ View all Source files size.go Click to show internal directories. Click to hide internal directories.