Documentation
¶
Index ¶
- Variables
- func Chain[T any](slices ...[]T) []T
- func CopyFile(dst, src string) error
- func Count(v ...bool) int
- func DeepCopy[T any](to T, from T, opts ...options.MustOption[copier.Option]) error
- func DoneOrSleep(ctx context.Context, duration time.Duration) bool
- func FilterSliceToMap[T any, K comparable, V any](collection []T, transform func(item T) (bool, K, V)) map[K]V
- func FindOrError[T any](collection []T, err error, predicate func(item T) bool) (zero T, errNil error)
- func Htpasswd(user, pass string) (string, error)
- func IsEmailValid(e string) bool
- func MakeHTTPS(url string) string
- func MapPtr[I, O any](in *I, f func(I) O) *O
- func MultiAppend[T any](slices ...[]T) []T
- func Must[T any](v T, err error) T
- func MustOk[T any](v T, ok bool) T
- func NewExecRunner() execRunner
- func Ptr[T any](in T) *T
- func PtrSlice[T any](in []T) []*T
- func ReverseSlice(s interface{})
- func Run(cmds []string, dir string, env []string) error
- func RunWithCommandOption(cmds []string, dir string, env []string) zoptions.Option[RunOpt]
- func RunWithOpt(opt RunOpt) error
- func RunWithOptV2(options ...zoptions.Option[RunOpt]) error
- func RunWithParentEnv(cmds []string, dir string, env []string, options ...func(opt *RunOpt)) error
- func RunWithParentEnvOption(opt *RunOpt) error
- func RunWithStdoutOption(stdout io.Writer) zoptions.Option[RunOpt]
- func SliceContains[S ~[]T, T comparable](items S, el T) bool
- func SliceFindUniques[T comparable](collection []T) []T
- func SliceOfPointersToValue[S []*E, E any](s S) []E
- func SliceOfValuesToPointer[S []E, E any](s S) []*E
- func TrimURLScheme(url string) string
- func TryFilter[T any, R any](collection []T, iteratee func(item T, index int) (bool, R, error)) ([]R, error)
- func TryMap[T any, R any](collection []T, mapper func(item T) (R, error)) ([]R, error)
- func URLJoin(base string, paths ...string) string
- func ValueSlice[T any](in []*T) []T
- func WriteLinesToFile(filename string, lines []string) error
- type CommandRunner
- type RunOpt
Constants ¶
This section is empty.
Variables ¶
var ( LoggingHttpTransport = &loghttp.Transport{ LogRequest: func(req *http.Request) { log.Trace().Msgf("[%p] %s %s %v", req, req.Method, req.URL, req.Header) }, LogResponse: func(resp *http.Response) { log.Trace().Msgf("[%p] %d %s", resp.Request, resp.StatusCode, resp.Request.URL) }, } )
Functions ¶
func FilterSliceToMap ¶ added in v0.1.0
func FilterSliceToMap[T any, K comparable, V any](collection []T, transform func(item T) (bool, K, V)) map[K]V
FilterSliceToMap iterates over a slice, turning T items into (K, V) associations, with possible filtering iteratee returns (bool, K, V): when the bool is false, K=>V is not included in the return value adapted from samber/lo
func FindOrError ¶ added in v0.1.0
func FindOrError[T any](collection []T, err error, predicate func(item T) bool) (zero T, errNil error)
FindOrError returns the first T in collection which matches the predicate, if none match, err is returned
func IsEmailValid ¶
IsEmailValid checks if the email provided passes the required structure and length. https://golangcode.com/validate-an-email-address/
func MapPtr ¶ added in v0.1.0
func MapPtr[I, O any](in *I, f func(I) O) *O
MapPtr runs f on the pointer value if it is not nil, or returns nil
func MultiAppend ¶ added in v0.1.0
func MultiAppend[T any](slices ...[]T) []T
func NewExecRunner ¶ added in v0.1.0
func NewExecRunner() execRunner
TODO: refactor RunWithOptV2 to this
func ReverseSlice ¶
func ReverseSlice(s interface{})
func RunWithCommandOption ¶ added in v0.1.0
func RunWithOpt ¶ added in v0.1.0
func RunWithOptV2 ¶ added in v0.1.0
TODO: refactor RunWithOpt to this
func RunWithParentEnv ¶ added in v0.1.0
RunWithParentEnv runs cmds in dir with additional environment variables supplied by env, in addition to the current process' environment (from os.Environ)
func RunWithParentEnvOption ¶ added in v0.1.0
RunWithParentEnv runs cmds in dir with additional environment variables supplied by env, in addition to the current process' environment (from os.Environ)
func RunWithStdoutOption ¶ added in v0.1.0
func SliceContains ¶ added in v0.1.0
func SliceContains[S ~[]T, T comparable](items S, el T) bool
func SliceFindUniques ¶ added in v0.1.0
func SliceFindUniques[T comparable](collection []T) []T
func SliceOfPointersToValue ¶ added in v0.1.0
func SliceOfPointersToValue[S []*E, E any](s S) []E
func SliceOfValuesToPointer ¶ added in v0.1.0
func SliceOfValuesToPointer[S []E, E any](s S) []*E
func TrimURLScheme ¶ added in v0.1.0
TrimURLScheme removes https:// or http:// scheme from the start of a url string
func TryFilter ¶ added in v0.1.0
func TryFilter[T any, R any](collection []T, iteratee func(item T, index int) (bool, R, error)) ([]R, error)
TryFilter filters a collection, but can abort when an error is returned by the iteratee when an error is returned, the collection return value will be empty
func TryMap ¶ added in v0.1.0
TryMap maps collection through a fallible mapper, returning the mapped collection and any error when an error is returned, the failed inputs will have a corresponding zero value in the returned collection
func ValueSlice ¶ added in v0.1.0
func ValueSlice[T any](in []*T) []T