bytesize

package
v1.12.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MPL-2.0 Imports: 3 Imported by: 1 module, 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 adds logic to help parse byte sizes in various forms such as gb, mb, GiB, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSize

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

ByteSize implements pflag.Value interface and is meant to be used with flags specifying a size in bytes. A value can be set before assigning to a flag to function as a default value.

func New

func New() *ByteSize

New creates a New ByteSize without a default unit.

func WithDefaultUnit

func WithDefaultUnit(unit string) *ByteSize

WithDefaultUnit creates a New ByteSize with a default unit.

func (*ByteSize) Bytes

func (bs *ByteSize) Bytes() uint64

Bytes returns the value in bytes.

func (*ByteSize) Gibibytes

func (bs *ByteSize) Gibibytes() uint64

Gibibytes returns the value in binary gigabytes.

func (*ByteSize) Gigabytes

func (bs *ByteSize) Gigabytes() uint64

Gigabytes returns the value in gigabytes.

func (*ByteSize) Mebibytetes

func (bs *ByteSize) Mebibytetes() uint64

Mebibytetes returns the value in binary megabytes.

func (*ByteSize) Megabytes

func (bs *ByteSize) Megabytes() uint64

Megabytes returns the value in megabytes.

func (*ByteSize) Set

func (bs *ByteSize) Set(in string) error

Set implements pflag.Value interface.

func (*ByteSize) SetDefaultUnit

func (bs *ByteSize) SetDefaultUnit(unit string)

SetDefaultUnit sets the default unit to use in case one wasn't specifies.

func (*ByteSize) String

func (bs *ByteSize) String() string

String returns the string representation of the value with the default unit if set.

func (*ByteSize) Type

func (bs *ByteSize) Type() string

Type implements pflag.Value interface (this will show up as the type next to the flag description).

Jump to

Keyboard shortcuts

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