diskusage

package
v0.0.0-...-4673ec4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 2 Imported by: 2

README

Package cloudeng.io/file/diskusage

CircleCI Go Report Card

import cloudeng.io/file/diskusage

Types

Type Base2Bytes
type Base2Bytes int64

Base2Bytes represents a number of bytes in base 2.

Constants
KiB, MiB, GiB, TiB, PiB, EiB
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.

Methods
func (b Base2Bytes) Num(value int64) float64
func (b Base2Bytes) Standardize() (float64, string)
Type Calculator
type Calculator interface {
	Calculate(int64) int64
	String() string
}
Functions
func NewIdentity() Calculator
func NewRAID0(stripeSize int64, numStripes int) Calculator
func NewSimple(blocksize int64) Calculator
Type DecimalBytes
type DecimalBytes int64

Base2Bytes represents a number of bytes in base 10.

Constants
KB, MB, GB, TB, PB, EB
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.

Methods
func (b DecimalBytes) Num(value int64) float64
func (b DecimalBytes) Standardize() (float64, string)
Type Identity
type Identity struct{}
Methods
func (i Identity) Calculate(size int64) int64
func (i Identity) String() string
Type RAID0
type RAID0 struct {
	// contains filtered or unexported fields
}
Methods
func (r0 RAID0) Calculate(size int64) int64
func (r0 RAID0) String() string
Type Simple
type Simple struct {
	// contains filtered or unexported fields
}
Methods
func (s Simple) Calculate(size int64) int64
func (s Simple) String() string

Examples

ExampleBase2Bytes
ExampleDecimalBytes

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

type Calculator interface {
	Calculate(int64) int64
	String() string
}

func NewIdentity

func NewIdentity() Calculator

func NewRAID0

func NewRAID0(stripeSize int64, numStripes int) Calculator

func NewSimple

func NewSimple(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)

type Identity

type Identity struct{}

func (Identity) Calculate

func (i Identity) Calculate(size int64) int64

func (Identity) String

func (i Identity) String() string

type RAID0

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

func (RAID0) Calculate

func (r0 RAID0) Calculate(size int64) int64

func (RAID0) String

func (r0 RAID0) String() string

type Simple

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

func (Simple) Calculate

func (s Simple) Calculate(size int64) int64

func (Simple) String

func (s Simple) String() string

Jump to

Keyboard shortcuts

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