Documentation
¶
Index ¶
- Variables
- func ChunkSlice[T any](items []T, size int) [][]T
- func FilterPartialDuplicates(in []string) []string
- func FindProjectRoot(depth int) (root string, err error)
- func HashFromStrings(values ...string) (string, error)
- func IsBool(in any) bool
- func IsFloat32(in any) bool
- func IsFloat64(in any) bool
- func IsInt(in any) bool
- func IsInt16(in any) bool
- func IsInt32(in any) bool
- func IsInt64(in any) bool
- func IsInt8(in any) bool
- func IsMap(in any) bool
- func IsSlice(in any) bool
- func IsString(in any) bool
- func IsStruct(in any) bool
- func IsTime(in any) bool
- func IsUint(in any) bool
- func IsUint16(in any) bool
- func IsUint32(in any) bool
- func IsUint64(in any) bool
- func IsUint8(in any) bool
- func MapHasKey[K comparable, V any](m map[K]V, key K) bool
- func MustHashFromStrings(values ...string) string
- func RandomBytes(n int) ([]byte, error)
- func RandomString(n int) (string, error)
- func RandomStringFromLetterSet(n int, l string) (string, error)
- func RandomStringURLSafe(n int) (string, error)
- func Set[T comparable](a []T) []T
- func ShouldHashFromStrings(values ...string) string
- func SliceContains[T comparable](arr []T, item T) bool
Constants ¶
This section is empty.
Variables ¶
var ErrNoValues = errors.New("no values provided")
Functions ¶
func ChunkSlice ¶ added in v0.1.4
ChuckSlice creates a slice of slices of a max chunk size. Given a size argument of 4:
[]int{1,2,3,4,5,6,7,9} // Becomes: [][]int{ {1,2,3,4}, {5,6,7,8}, {9} }
func FilterPartialDuplicates ¶ added in v0.1.6
FilterPartialDuplicates takes a slice of strings and filters out items that are a partial match for other items in the slice. For example:
[]string{"thing1", "thing that has thing1", "thing2", "thing that has thing2", "thing3"} // Becomes: []string{"thing1", "thing2", "thing3"}
func FindProjectRoot ¶ added in v0.1.0
FindProjectRoot finds the root of a Go project.
func HashFromStrings ¶ added in v0.1.3
HashFromStrings creates a SHA256 checksum from any number of input string values.
func MapHasKey ¶
func MapHasKey[K comparable, V any](m map[K]V, key K) bool
MapHasKey determines if a given map has an entry for a given key.
func MustHashFromStrings ¶ added in v0.1.7
MustHashFromStrings creates a SHA256 checksum from any number of input string values and panics on error.
func RandomBytes ¶ added in v0.0.5
RandomBytes generates cryptographically secure random bytes.
func RandomString ¶ added in v0.0.5
RandomString generates a cryptographically secure random string.
func RandomStringFromLetterSet ¶ added in v0.0.5
RandomStringFromLetterSet generates a cryptographically secure random string from a given set of letters. RandomStringFromLetterSet is used as the backend for RandomString and RandomStringURLSafe.
func RandomStringURLSafe ¶ added in v0.0.5
RandomStringURLSafe generates a cryptographically secure random string that is URL safe.
func Set ¶ added in v0.1.5
func Set[T comparable](a []T) []T
Set creates a slice of unique elements from an input slice. Order is not guaranteed.
Example ¶
Set([]string{"one", "two", "two"}) // []string{"one", "two"}
func ShouldHashFromStrings ¶ added in v0.1.7
ShouldHashFromStrings creates a SHA256 checksum from any number of input string values. On error, a `__` joined string of input values is returned.
func SliceContains ¶
func SliceContains[T comparable](arr []T, item T) bool
SliceContains determines if a given slice contains a given item.
Types ¶
This section is empty.