utils

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertStrings

func AssertStrings(as []any) ([]string, error)

AssertStrings converts a slice of any into a slice of strings.

func BytesAreEmptyIsh

func BytesAreEmptyIsh(b []byte) bool

BytesAreEmptyIsh checks if the provided byte slice is practically empty. Can handle cases where a nil pointer or empty struct were marshalled to YAML.

func CountDir

func CountDir(dir string) (int, int64, error)

CountDir returns the number of files in a directory and the total size.

func FilterNil

func FilterNil[T any](list []*T) []*T

FilterNil filters nil entries from a list.

func FmtSemver

func FmtSemver(s string) string

FmtSemver forces a string formatted as a semver version with "v" prefix.

func IndexIfOK added in v0.2.0

func IndexIfOK[T any](list []T, i int) (T, bool)

IndexIfOK returns the value at the index if it is a valid index for the slice.

func PrettyBytes

func PrettyBytes(size int64) string

PrettyBytes returns the number of bytes formatted for human readability.

func TerminalWidth

func TerminalWidth(fallback int) int

TerminalWidth returns the width of the terminal, using fallback if it can't determine width.

func ToAny added in v0.2.0

func ToAny[T any](list []T) []any

ToAny casts a slice to []any.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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