bytesize

package
v2.27.7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bytesize provides easy conversions from human readable strings (eg. 10MB) to bytes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSize

type ByteSize uint64

ByteSize is the size in bytes

const (
	KB ByteSize = 1000
	MB ByteSize = 1000 * KB
	GB ByteSize = 1000 * MB
	TB ByteSize = 1000 * GB
	PB ByteSize = 1000 * TB
	EB ByteSize = 1000 * PB

	KiB ByteSize = 1024
	MiB ByteSize = 1024 * KiB
	GiB ByteSize = 1024 * MiB
	TiB ByteSize = 1024 * GiB
	PiB ByteSize = 1024 * TiB
	EiB ByteSize = 1024 * PiB
)

List of available byte sizes NOTE: max is exabyte as we convert to uint64

func Parse

func Parse(s string) (ByteSize, error)

Parse parses a Bytesize from a string

func (ByteSize) Bytes

func (b ByteSize) Bytes() uint64

Bytes converts the ByteSize to an uint64

func (ByteSize) String

func (b ByteSize) String() string

String converts the ByteSize to a string

Jump to

Keyboard shortcuts

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