text

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 15 Imported by: 17

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func Add added in v1.5.10

func Add(a time.Time, b time.Duration) time.Time

func After added in v1.5.10

func After(a, b time.Time) bool

func AfterDuration added in v1.5.10

func AfterDuration(a, b time.Duration) bool

func AfterOrEqual added in v1.5.10

func AfterOrEqual(a, b time.Time) bool

func AfterOrEqualDuration added in v1.5.10

func AfterOrEqualDuration(a, b time.Duration) bool

func Age added in v1.5.10

func Age(s string) time.Duration

func Before added in v1.5.10

func Before(a, b time.Time) bool

func BeforeDuration added in v1.5.10

func BeforeDuration(a, b time.Duration) bool

func BeforeOrEqual added in v1.5.10

func BeforeOrEqual(a, b time.Time) bool

func BeforeOrEqualDuration added in v1.5.10

func BeforeOrEqualDuration(a, b time.Duration) bool

func Date added in v1.5.10

func Date(s string) time.Time

func Duration added in v1.5.10

func Duration(s string) time.Duration

func EqualDuration added in v1.5.10

func EqualDuration(a, b time.Duration) bool

func EqualTime added in v1.5.10

func EqualTime(a, b time.Time) bool

func GetTemplateFuncs added in v1.5.9

func GetTemplateFuncs() gotemplate.FuncMap

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 MakeExpressionEnvs added in v1.5.10

func MakeExpressionEnvs(envs map[string]interface{}) map[string]interface{}

func MakeExpressionOptions added in v1.5.10

func MakeExpressionOptions(envs map[string]interface{}) []expr.Option

func ParseDuration added in v1.5.10

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

func SafeRead

func SafeRead(r io.Reader) string

func Sub added in v1.5.10

func Sub(a, b time.Time) time.Duration

func Template

func Template(template string, vars interface{}) (string, error)

Template templates out a template using gomplate

func TemplateWithDelims added in v1.5.8

func TemplateWithDelims(template, openingDelims, closingDelims string, vars interface{}) (string, error)

TemplateWithDelims templates out a template using gomplate using the given opening and closing Delims

func ToFile

func ToFile(text string, ext string) string

ToFile saves text as a temp file with an extension

Types

This section is empty.

Jump to

Keyboard shortcuts

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