humansize

package
v0.0.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 3 Imported by: 0

README

Human-readable Sizes

Yet another 1k -> 1024 library, to avoid external dependencies.

Documentation

Overview

Package humansize - Human-readable data sizes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Size

type Size uint64

Size allows us to give users the option to use suffixes like g and K. It is also suitable for passing to flag.TextVar.

func MustNew

func MustNew(s string) Size

MustNew retruns a new Size into which is unmarshalled s. If Unmarshalling fails, MustNew panics.

func (*Size) MarshalText

func (s *Size) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler. It is just s.String with extra steps.

func (Size) String

func (s Size) String() string

String implements fmt.Stringer and is more or less the inverse of UnmarshalText.

func (*Size) UnmarshalText

func (s *Size) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. A nil or empty slices unmarshals to 0.

Jump to

Keyboard shortcuts

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