utils

package
v0.5.14 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func Any added in v0.4.19

func Any[T any](s []T, f func(T) bool) 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 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 HashString

func HashString(s string) string

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 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 Ptr

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

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 SafeDereference

func SafeDereference(s *string) string

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 ZipReaderFromResponse

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

Types

type CompareResult

type CompareResult[T any] struct {
	OnlyInA []T
	OnlyInB []T
	InBoth  []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

Jump to

Keyboard shortcuts

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