utils

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 6 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 ParseCookies

func ParseCookies(cookie string) ([]*http.Cookie, error)

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](a, b []T, keyFn func(in T) string) ([]T, []T)

func SortInt32Slice

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

func StringFirstN

func StringFirstN(s string, n int) string

Taken from kAdor 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