size

package
v0.0.0-...-e8a267e Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSize

type ByteSize uint64

ByteSize represents a number of bytes. It can be unmarshalled from a JSON number or a JSON string such as "10k" or "16mb" or "32 PB".

func FromInt64

func FromInt64(x int64) (size ByteSize, err error)

FromInt64 converts an int64 to a ByteSize if it is non-negative.

func FromString

func FromString(s string) (ByteSize, error)

FromString converts a string like "10 mb" or "16k" to a ByteSize. See units.RAMInBytes for more details.

func (ByteSize) MarshalJSON

func (z ByteSize) MarshalJSON() ([]byte, error)

MarshalJSON encodes the ByteSize as a JSON string.

func (ByteSize) String

func (z ByteSize) String() string

func (*ByteSize) UnmarshalJSON

func (z *ByteSize) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON converts a JSON number or string to a ByteSize. If b is a JSON number, it must be a positive integer. If b is a JSON string, it must be parsable by units.RAMInBytes.

type NegativeSizeError

type NegativeSizeError struct {
	Size int64
}

NegativeSizeError is returned when parsing a negative size.

func (NegativeSizeError) Error

func (e NegativeSizeError) Error() string

Jump to

Keyboard shortcuts

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