Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseToBytes ¶
Types ¶
type Base2Bytes ¶
type Base2Bytes int64
Base2Bytes represents a number of bytes in base 2.
Example ¶
package main import ( "fmt" "cloudeng.io/file/diskusage" ) func main() { fmt.Println(diskusage.KiB.Num(512)) fmt.Println(diskusage.KiB.Num(2048)) fmt.Println(diskusage.GiB.Num(1073741824)) fmt.Println(diskusage.Base2Bytes(1024).Standardize()) fmt.Println(diskusage.Base2Bytes(1536).Standardize()) fmt.Println(diskusage.Base2Bytes(1610612736).Standardize()) }
Output: 0.5 2 1 1 KiB 1.5 KiB 1.5 GiB
const ( KiB Base2Bytes = 1024 MiB Base2Bytes = KiB * 1024 GiB Base2Bytes = MiB * 1024 TiB Base2Bytes = GiB * 1024 PiB Base2Bytes = TiB * 1024 EiB Base2Bytes = PiB * 1024 )
Values for Base2Bytes.
func (Base2Bytes) Num ¶
func (b Base2Bytes) Num(value int64) float64
func (Base2Bytes) Standardize ¶
func (b Base2Bytes) Standardize() (float64, string)
type Calculator ¶
Calculator is used to calculate the size of a file or directory based on either its size in bytes (often referred to as its apparent size) and/or the number of storage blocks it occupies. Some file systems support sparse files (most unix filesystems) where the number of blocks occupied by a file is less than the number of bytes it represents, hence, the term 'apparent size'.
func NewBlock ¶
func NewBlock(blocksize int64) Calculator
Block uses the number of blocks occupied by a file to calculate its size.
func NewIdentity ¶
func NewIdentity() Calculator
func NewRAID0 ¶
func NewRAID0(stripeSize int64, numStripes int) Calculator
func NewRoundup ¶
func NewRoundup(blocksize int64) Calculator
type DecimalBytes ¶
type DecimalBytes int64
Base2Bytes represents a number of bytes in base 10.
Example ¶
package main import ( "fmt" "cloudeng.io/file/diskusage" ) func main() { fmt.Println(diskusage.KB.Num(500)) fmt.Println(diskusage.KB.Num(2000)) fmt.Println(diskusage.GB.Num(1000000000)) fmt.Println(diskusage.DecimalBytes(1000).Standardize()) fmt.Println(diskusage.DecimalBytes(1500).Standardize()) fmt.Println(diskusage.DecimalBytes(1500000000).Standardize()) }
Output: 0.5 2 1 1 KB 1.5 KB 1.5 GB
const ( KB DecimalBytes = 1000 MB DecimalBytes = KB * 1000 GB DecimalBytes = MB * 1000 TB DecimalBytes = GB * 1000 PB DecimalBytes = TB * 1000 EB DecimalBytes = PB * 1000 )
Values for DecimalBytes.
func (DecimalBytes) Num ¶
func (b DecimalBytes) Num(value int64) float64
func (DecimalBytes) Standardize ¶
func (b DecimalBytes) Standardize() (float64, string)
Click to show internal directories.
Click to hide internal directories.