humanity

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: Unlicense Imports: 5 Imported by: 1

README

humanity

import "codeberg.org/mgkeller/go-humanity"

Overview

Index

Package files

humanity.go

func ByteFormat

func ByteFormat[N Number](numIn N) string

ByteFormat returns a human-readable string representation of a byte count

func DurationFormat

func DurationFormat[N Number](ns N) string

DurationFormat returns a human-readable string representation of nanosecond number

func StringAsBytes

func StringAsBytes(s string) (int64, error)

StringAsBytes will convert WHOLE NUMBER stringified byte-storage sizes to the corresponding int64 byte value. Decimals bomb by design. Suffixes above Petabyte are not supported due to int64 constraints. Suffixes must be [KMGTP]*?B). Case-insensitive.

type Number

type Number interface {
    constraints.Integer | constraints.Float
}

Number is an abstraction to support generic numbers as inputs


Generated by godoc2md

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteFormat

func ByteFormat[N Number](numIn N) string

ByteFormat returns a human-readable string representation of a byte count

func DurationFormat

func DurationFormat[N Number](ns N) string

DurationFormat returns a human-readable string representation of nanosecond number

func StringAsBytes

func StringAsBytes(s string) (int64, error)

StringAsBytes will convert WHOLE NUMBER stringified byte-storage sizes to the corresponding int64 byte value. Decimals bomb by design. Suffixes above Petabyte are not supported due to int64 constraints. Suffixes must be “[KMGTP]*?B)“. Case-insensitive.

Types

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

Number is an abstraction to support generic numbers as inputs

Jump to

Keyboard shortcuts

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