datasize

package
v0.48.5 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package datasize provides a ByteSize type for representing data sizes in bytes, and functions for parsing and formatting ByteSize values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSize

type ByteSize = datasize.ByteSize

ByteSize is a type for representing data sizes in bytes.

func MustParse

func MustParse(t []byte) ByteSize

func MustParseString

func MustParseString(s string) ByteSize

func Parse

func Parse(t []byte) (ByteSize, error)

func ParseString

func ParseString(s string) (ByteSize, error)

type Opt

type Opt struct {
	options.BaseOpt
	// contains filtered or unexported fields
}

Opt is an options.Opt for format.Format.

func NewOpt

func NewOpt(key string, flag *options.Flag, defaultVal ByteSize,
	usage, help string, tags ...string,
) Opt

NewOpt returns a new datasize.Opt instance.

func (Opt) Default

func (op Opt) Default() ByteSize

Default returns the default value of op.

func (Opt) DefaultAny

func (op Opt) DefaultAny() any

DefaultAny implements options.Opt.

func (Opt) Get

func (op Opt) Get(o options.Options) ByteSize

Get returns op's value in o. If o is nil, or no value is set, op's default value is returned.

func (Opt) GetAny

func (op Opt) GetAny(o options.Options) any

GetAny implements options.Opt.

func (Opt) Process

func (op Opt) Process(o options.Options) (options.Options, error)

Process implements options.Processor. It converts matching string or integer values in o into ByteSize. If no match found, the input arg is returned unchanged. Otherwise, a clone is returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳