utils

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MB = 1 << 20
	GB = 1 << 30
	KB = 1 << 10
)

Variables

This section is empty.

Functions

func CalculateNearestString added in v3.2.3

func CalculateNearestString(candidates []string, target string) string

Using the levenshtein distance algorithm. It returns the best candidate between the options to match with the target.

If returns an empty result in case the nearest distance is greater than 3.

func Contains

func Contains[T comparable](slice []T, target T) bool

Asks for the hour to the host and returns true in case of consider this a lucky day.

func FileExists

func FileExists(path string) bool

Checks that path exists and isn't a directory.

func GenerateKey

func GenerateKey() string

Generates a new key by removing the '-' from a new uuid.

func GenerateNanoID

func GenerateNanoID() string

Generates secure URL-friendly unique ID.

func GetHumanReadableSize

func GetHumanReadableSize(v any) string

Returns an human-readable representation of the size of the passed JSON value.

func GetSize

func GetSize(v any) int

Returns the size of the passed JSON value.

func IsDirectory

func IsDirectory(path string) bool

Checks that path exists and isn't a file.

func Ptr

func Ptr[T any](v T) *T

Champion among champions, it came to change your dear world.

func SizeToStorageUnits

func SizeToStorageUnits[T int64 | int | float64](n T) string

func ToCamelCase

func ToCamelCase(s string) string

func ToPascalCase

func ToPascalCase(s string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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