size

package
v0.0.0-...-c18a219 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	B = 1 << (10 * iota)
	KB
	MB
	GB
	TB
	PB
	EB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Space     bool
	Short     bool
	Precision int
}

Options represents format options

type Size

type Size uint64

Size represents human-readable bytes.

func Parse

func Parse(value string) (s Size, err error)

Parse parses human-readable bytes string to Size. For example, 1 K/1 KB(or 1K) will return 1024 bytes.

func (Size) Format

func (s Size) Format(opts Options) string

Format formats Size to human-readable string with specified options. For example, 1024 bytes will return 1 KB.

func (Size) MarshalJSON

func (s Size) MarshalJSON() ([]byte, error)

func (Size) String

func (s Size) String() string

String formats Size to human-readable string with default options. For example, 1024 bytes will return '1 KB'.

func (*Size) Unmarshal

func (s *Size) Unmarshal(i interface{}) (err error)

Unmarshal implements config.Unmarshaler interface.

func (*Size) UnmarshalJSON

func (s *Size) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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