Documentation ¶
Index ¶
- Constants
- func All[T any](s []T, f func(T) bool) bool
- func Any[T any](s []T, f func(T) bool) bool
- func Capitalize(s string) string
- func Contains[T comparable](s []T, v T) bool
- func Exists(path string) bool
- func ExpandHome(path *string)
- func FindFirst[T any](s []T, f func(T) bool) *T
- func FirstOrDefault[T any](arr []T, fallback T) T
- func Keys[K comparable, V any](m map[K]V) []K
- func Map[TIn any, TOut any](s []TIn, f func(TIn) TOut) []TOut
- func Max(arr []int) int
- func Pad(s string, maxLen int) string
- func Transpose[T any](slice [][]T) [][]T
- func Values[K comparable, V any](m map[K]V) []V
- func Where[T any](s []T, f func(T) bool) []T
- type ApisenseTime
Constants ¶
const ApisenseTimeFormat = "2006-01-02T15-04-05.000Z"
ApisenseTimeFormat is the go time format representation of ApisenseTime
Variables ¶
This section is empty.
Functions ¶
func Capitalize ¶
Capitalize coverts the first char in the string to uppercase
func Contains ¶
func Contains[T comparable](s []T, v T) bool
Contains returns whether the given slice contains the given element
func ExpandHome ¶
func ExpandHome(path *string)
ExpandHome replaes the character "~" in the string with the content of the "HOME" environment variable in place
func FindFirst ¶
FindFirst return a reference to the first element of the slice that matches the predicate. It returns nil if the slice is nil or empty or if no item matches the predicate.
func FirstOrDefault ¶
func FirstOrDefault[T any](arr []T, fallback T) T
FirstOrDefault returns the first value in arr if it has items else fallback
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
Keys returns the keys of a map in a non-deterministic fashion
func Transpose ¶
func Transpose[T any](slice [][]T) [][]T
Transpose returns the matrix transposed from (nxm) to (mxn)
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
Values returns the values of a map in non-deterministic fashion
Types ¶
type ApisenseTime ¶
ApisenseTime is the time format used in everything apisense
func ParseTime ¶
func ParseTime(s string) (ApisenseTime, error)
ParseTime parses a string into an ApisenseTime according to ApisenseTimeFormat
func (ApisenseTime) MarshalJSON ¶
func (t ApisenseTime) MarshalJSON() ([]byte, error)
func (ApisenseTime) String ¶
func (t ApisenseTime) String() string
String returns the formatted representation according to ApisenseTimeFormat
func (*ApisenseTime) UnmarshalJSON ¶
func (t *ApisenseTime) UnmarshalJSON(b []byte) error