utils

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ISO8601Format = "2006-01-02T15:04:05.000"

Variables

View Source
var GitLister gitLister = commandLineGitLister{}

Functions

func AddToWhitespaceSeparatedStringList added in v0.17.0

func AddToWhitespaceSeparatedStringList(s string, item string) string

func All added in v0.17.0

func All[T any](s []T, f func(T) bool) bool

func Any added in v0.4.19

func Any[T any](s []T, f func(T) bool) bool

func CheckForValidLanguageCode added in v0.17.0

func CheckForValidLanguageCode(languageCode string) bool

supported languages are declared in `supportedLanguageCodes` at the start of this file

func CompareFirstTwoDecimals added in v0.17.0

func CompareFirstTwoDecimals(a, b float64) bool

func Concurrently

func Concurrently(fns ...func() (any, error)) concurrentResultSlice

func Contains added in v0.5.14

func Contains[T comparable](s []T, el T) bool

func ContainsAll added in v0.17.0

func ContainsAll[T comparable](s []T, needed []T) bool

func ContainsInWhitespaceSeparatedStringList added in v0.17.0

func ContainsInWhitespaceSeparatedStringList(s string, item string) bool

func Debounce added in v0.17.0

func Debounce(fn func(), delay time.Duration) func()

func Disjoin added in v0.5.14

func Disjoin[T any](a []T, predicate func(el T) bool) ([]T, []T)

func EmptyThenNil added in v0.5.1

func EmptyThenNil(s string) *string

func ErrGroup

func ErrGroup[T any](limit int) *errGroup[T]

func Filter

func Filter[T any](s []T, f func(T) bool) []T

func Find added in v0.5.1

func Find[T any](s []T, f func(T) bool) (T, bool)

func Flat

func Flat[T any](s [][]T) []T

func GetDirFromPath added in v0.19.0

func GetDirFromPath(path string) string

func HashString

func HashString(s string) string

func Intersect added in v0.17.0

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

func Map

func Map[T, U any](s []T, f func(T) U) []U

func Mapper

func Mapper[Key comparable, T any](s []T, f func(T) Key) map[Key]T

func MergeUnrelated added in v0.5.15

func MergeUnrelated[A, B any](a []A, b []B) []any

func Or added in v0.5.1

func Or[T any](
	val *T,
	fallback *T,
) *T

func OrDefault added in v0.5.1

func OrDefault[T any](val *T, def T) T

func PrintBuildInformation added in v0.17.0

func PrintBuildInformation()

func Ptr

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

func ReadCsv added in v0.17.0

func ReadCsv(reader *csv.Reader, fn func(row []string) error) (int, error)

func ReadCsvFile added in v0.18.0

func ReadCsvFile(filePath string) ([]map[string]any, error)

func ReadCsvInChunks added in v0.17.0

func ReadCsvInChunks(reader *csv.Reader, chunkSize int, fn func(rows [][]string) error) (int, error)

func ReadFileFromGitRef added in v0.17.0

func ReadFileFromGitRef(path string, commitSha string, fileName string) ([]byte, error)

func ReadZipFile

func ReadZipFile(zf *zip.File) ([]byte, error)

func Reduce

func Reduce[T, U any](s []T, f func(U, T) U, init U) U

func RemoveFromWhitespaceSeparatedStringList added in v0.17.0

func RemoveFromWhitespaceSeparatedStringList(s string, item string) string

func RemovePrefixInsensitive added in v0.17.0

func RemovePrefixInsensitive(input string, prefix string) string

func RunsInCI added in v0.17.0

func RunsInCI() bool

func SafeDereference

func SafeDereference(s *string) string

func ShannonEntropy added in v0.17.0

func ShannonEntropy(str string) float64

func SlicePtr added in v0.17.0

func SlicePtr[T any](t []T) []*T

func Some added in v0.4.19

func Some[T any](s []T, f func(T) bool) bool

func UniqBy added in v0.5.1

func UniqBy[T any, K comparable](s []T, f func(T) K) []T

func Unzip added in v0.5.1

func Unzip(src, dest string) error

func Values added in v0.17.0

func Values[K comparable, T any](m map[K]T) []T

func ZipReaderFromResponse

func ZipReaderFromResponse(resp *http.Response) (*zip.Reader, error)

Types

type CompareResult

type CompareResult[T any] struct {
	OnlyInA []T
	OnlyInB []T
	InBoth  []T // returns the elements in A

	InBothB []T
}

func CompareSlices

func CompareSlices[T any, K comparable](a, b []T, serializer func(T) K) CompareResult[T]

type Date

type Date time.Time

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) error

Implement Marshaler and Unmarshaler interface

type GitVersionInfo added in v0.17.0

type GitVersionInfo struct {
	IsTag         bool
	BranchOrTag   string
	DefaultBranch *string
}

func GetAssetVersionInfo added in v0.17.0

func GetAssetVersionInfo(path string) (GitVersionInfo, error)

type GoroutineFireAndForgetSynchronizer added in v0.17.0

type GoroutineFireAndForgetSynchronizer struct{}

func NewFireAndForgetSynchronizer added in v0.17.0

func NewFireAndForgetSynchronizer() *GoroutineFireAndForgetSynchronizer

func (*GoroutineFireAndForgetSynchronizer) FireAndForget added in v0.17.0

func (f *GoroutineFireAndForgetSynchronizer) FireAndForget(fn func())

super simple: create a goroutine and call the function in it

type SyncFireAndForgetSynchronizer added in v0.17.0

type SyncFireAndForgetSynchronizer struct {
}

func NewSyncFireAndForgetSynchronizer added in v0.17.0

func NewSyncFireAndForgetSynchronizer() *SyncFireAndForgetSynchronizer

func (*SyncFireAndForgetSynchronizer) FireAndForget added in v0.17.0

func (f *SyncFireAndForgetSynchronizer) FireAndForget(fn func())

just don't use a goroutine, but call the function directly

Jump to

Keyboard shortcuts

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