utils

package
v0.0.0-...-6f6a9a1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: GPL-3.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlphaMapKeys

func AlphaMapKeys[V any](m map[string]V) []string

func Contains

func Contains[T comparable](xs []T, x T) bool

Contains returns true if slice contains value.

func CopyFile

func CopyFile(sourcePath, destPath string) error

func GetLocalIp

func GetLocalIp() (net.IP, error)

func InfoPrompt

func InfoPrompt(prompt string)

InfoPrompt displays an information prompt for use with a controller.

func IsEmptyDir

func IsEmptyDir(path string) (bool, error)

func IsZip

func IsZip(path string) bool

func ListZip

func ListZip(path string) ([]string, error)

ListZip returns a slice of all filenames in a zip file.

func MapKeys

func MapKeys[K comparable, V any](m map[K]V) []K

MapKeys returns a list of all keys in a map.

func Max

func Max[T constraints.Ordered](xs []T) T

Max returns the highest value in a slice.

func Md5Sum

func Md5Sum(path string) (string, error)

Md5Sum returns the MD5 hash of a file on disk.

func Min

func Min[T constraints.Ordered](xs []T) T

Min returns the lowest value in a slice.

func MoveFile

func MoveFile(sourcePath, destPath string) error

MoveFile moves a file. Supports moving between filesystems.

func RandomElem

func RandomElem[T any](xs []T) (T, error)

RandomElem picks and returns a random element from a slice.

func RemoveEmptyDirs

func RemoveEmptyDirs(path string) error

RemoveEmptyDirs removes all empty folders in a path, including folders containing only empty folders and the path itself.

func RemoveFileExt

func RemoveFileExt(s string) string

func Reverse

func Reverse[S ~[]E, E any](s S)

func SortedMapKeys

func SortedMapKeys[V any](m map[string]V) []string

SortedMapKeys return a sorted list of all keys in a map.

func StripBadFileChars

func StripBadFileChars(s string) string

StripBadFileChars removes all characters from a string that are not allowed in filenames.

func StripChars

func StripChars(s string, chars string) string

func WaitForInternet

func WaitForInternet(maxTries int) bool

func YesOrNoPrompt

func YesOrNoPrompt(prompt string) bool

YesOrNoPrompt displays a simple yes/no prompt for use with a controller.

Types

This section is empty.

Jump to

Keyboard shortcuts

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