text

package
v1.30.5 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 17

Documentation

Index

Constants

View Source
const (
	BYTE = 1 << (10 * iota)
	KILOBYTE
	MEGABYTE
	GIGABYTE
	TERABYTE
	PETABYTE
	EXABYTE
)
View Source
const (
	KILO = 1000
	MEGA = 1000 * KILO
	GIGA = 1000 * MEGA
)

Variables

This section is empty.

Functions

func Age added in v1.5.10

func Age(d time.Time) string

func Bytes added in v1.30.5

func Bytes(indent, b []byte) []byte

Bytes returns b with each line in b prefixed by indent.

func HumanizeBytes added in v1.5.2

func HumanizeBytes(size interface{}) string

ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth. The following units are available:

E: Exabyte
P: Petabyte
T: Terabyte
G: Gigabyte
M: Megabyte
K: Kilobyte
B: Byte

The unit that results in the smallest number greater than or equal to 1 is always chosen. Input is the size in bytes.

func HumanizeDuration added in v1.5.2

func HumanizeDuration(d time.Duration) string
Returns a string representing of a duration in the form "3d1h3m".

Leading zero units are omitted. As a special case, durations less than one second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading digit is non-zero. Duration more than a day or more than a week lose granularity and are truncated to resp. days-hours-minutes and weeks-days-hours. The zero duration formats as 0s.

func HumanizeInt added in v1.29.1

func HumanizeInt(size interface{}) string

func NewWriter added in v1.30.5

func NewWriter(w io.Writer, indent string) io.Writer

NewWriter returns an io.Writer that prefixes the lines written to it with indent and then writes them to w. The writer returns the number of bytes written to the underlying Writer.

func ParseDuration added in v1.5.10

func ParseDuration(val string) (*time.Duration, error)

func SafeRead

func SafeRead(r io.Reader) string

func String added in v1.30.5

func String(indent, s string) string

String returns s with each line in s prefixed by indent.

Types

This section is empty.

Jump to

Keyboard shortcuts

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