utils

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanFilePath

func CleanFilePath(filePath string) (string, bool)

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

Taken from https://gist.github.com/dopey/c69559607800d2f2f90b1b1ed4e550fb GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func RemoveSliceDuplicates

func RemoveSliceDuplicates[T comparable](in []T) []T

func SliceInt32ToInt

func SliceInt32ToInt(in []int32) (out []int)

func SliceUint64ToInt64

func SliceUint64ToInt64(in []uint64) (out []int64)

func SlicesDifference

func SlicesDifference[T comparable](a, b []T) ([]T, []T)

SlicesDifference duplicates of values are ignored

func SlicesDifferenceFunc

func SlicesDifferenceFunc[T comparable, S comparable](a, b []T, keyFn func(in T) S) (added []T, removed []T)

func Slug added in v0.9.4

func Slug(in string) string

func SlugNoDots added in v0.9.4

func SlugNoDots(in string) string

func SortInt32Slice

func SortInt32Slice[T constraints.Ordered](x []T)

func StringFirstN

func StringFirstN(s string, n int) string

Taken from "KAdot" here: https://stackoverflow.com/a/41604514

Types

type Comparable

type Comparable[T constraints.Ordered] []T

Comparable generic for sorting in increasing order.

func (Comparable[T]) Len

func (x Comparable[T]) Len() int

func (Comparable[T]) Less

func (x Comparable[T]) Less(i, j int) bool

func (Comparable[T]) Swap

func (x Comparable[T]) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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