Documentation ¶
Index ¶
- func ArrayDiffInt(a []int, b []int) []int
- func ArrayDiffInt32(a []int32, b []int32) []int32
- func ArrayDiffStr(a []string, b []string) []string
- func ArrayDiffUuid(a []uuid.UUID, b []uuid.UUID) []uuid.UUID
- func ArrayDiffUuidRef(a []*uuid.UUID, b []*uuid.UUID) []*uuid.UUID
- func ArrayFillStr(value string, count int) []string
- func ArrayFilterAndJoinStr(a []string, sep string) string
- func ArrayFilterFnStr(a []string, fn func(v string) bool) []string
- func ArrayFilterStr(a []string) []string
- func ArrayIncludesInt(haystack []int, needle int) bool
- func ArrayIncludesInt32(haystack []int32, needle int32) bool
- func ArrayIncludesStr(haystack []string, needle string) bool
- func ArrayIncludesUUID(haystack []uuid.UUID, needle uuid.UUID) bool
- func ArrayMapStr(a []string, fn func(v string) string) []string
- func BoolFromSqlTinyInt(v int8) bool
- func BoolRef(v bool) *bool
- func CliAsk(question string, defaultAnswer string) string
- func CliAskPassword(question string) string
- func CliAskRequired(question string, defaultAnswer string) string
- func CliConfirm(question string) bool
- func DecimalFromRef(v *decimal.Decimal) decimal.Decimal
- func DecimalRef(v decimal.Decimal) *decimal.Decimal
- func DecimalRefFromSql(v decimal.NullDecimal) *decimal.Decimal
- func DerefPtrSlice[T any](s []*T) []T
- func DerefPtrSliceSlice[T any](s [][]*T) [][]T
- func DiffSlice[T comparable](a []T, b []T) []T
- func FilterSlice[T any](s []T, f func(T) bool) []T
- func FormatDate(t time.Time, format string) string
- func GenerateRandomKey(length int) []byte
- func GenerateRandomString(length int, charset []rune) string
- func GqlTime(v time.Time) string
- func GqlTimeRefSql(v sql.NullTime) *string
- func IfThenElse[T any](cond bool, t T, f T) T
- func Int32FromRef(v *int32) int32
- func Int32MustParse(v string) int32
- func Int32Ref(v int32) *int32
- func Int64FromRef(v *int64) int64
- func Int64MustParse(v string) int64
- func Int64Ref(v int64) *int64
- func IntArray2StrArray(in []int) []string
- func IntFromRef(v *int) int
- func IntRef(v int) *int
- func IntRefFromSql(v sql.NullInt32) *int
- func JoinIntArray(in []int, sep string) string
- func MapSlice[IN any, OUT any](s []IN, f func(IN) OUT) []OUT
- func NewDefaultLogger() zerolog.Logger
- func Plural(count int, singular string, plural string) string
- func PrintErrWithStack(err error)
- func RenderTemplatePlain(tplStr string, data interface{}) (string, error)
- func ScreamingSnakeCaseToHuman(s string) string
- func SendSlackWebhook(ctx context.Context, webhookUrl string, message SlackMessagePayload) error
- func SliceIncludes[T comparable](s []T, v T) bool
- func SliceToPtrSlice[T any](s []T) []*T
- func SqlNullDecimalRef(v *decimal.Decimal) decimal.NullDecimal
- func SqlNullInt32(v int32) sql.NullInt32
- func SqlNullIntRef(v *int) sql.NullInt32
- func SqlNullStr(v string) sql.NullString
- func SqlNullStrRef(v *string) sql.NullString
- func SqlNullTime(v time.Time) sql.NullTime
- func SqlNullTimeRef(v *time.Time) sql.NullTime
- func SqlNullUuid(v uuid.UUID) uuid.NullUUID
- func SqlNullUuidRef(v *uuid.UUID) uuid.NullUUID
- func SqlTimeToStrRef(v sql.NullTime) *string
- func SqlTinyIntFromBool(v bool) int8
- func StrFromRef(v *string) string
- func StrNilIfEmpty(v string) *string
- func StrRef(v string) *string
- func StrRefFromSql(v sql.NullString) *string
- func StrSliceToStrRefSlice(v []string) []*string
- func TimeFromGqlTime(v string) (time.Time, error)
- func TimeFromRef(v *time.Time) time.Time
- func TimeRef(v time.Time) *time.Time
- func TimeRefFromGqlTimeRef(v *string) *time.Time
- func TimeRefFromSql(v sql.NullTime) *time.Time
- func ToPtr[T any](v T) *T
- func TruncateStr(str string, maxLen int) string
- func TruncateStrBytes(str string, maxBytes int) string
- func UuidRef(id uuid.UUID) *uuid.UUID
- func UuidRefFromSql(v uuid.NullUUID) *uuid.UUID
- type ClientError
- type ErrAndPanicGroup
- type SlackMessagePayload
- type SlackWebhookClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayDiffInt ¶ added in v0.0.7
ArrayDiffInt returns a slice of all values from a that are not in b. Deprecated: use DiffSlice instead.
func ArrayDiffInt32 ¶ added in v0.0.2
ArrayDiffInt32 returns a slice of all values from a that are not in b. Deprecated: use DiffSlice instead.
func ArrayDiffStr ¶ added in v0.0.2
ArrayDiffStr returns a slice of all values from a that are not in b. Deprecated: use DiffSlice instead.
func ArrayDiffUuid ¶ added in v0.2.6
ArrayDiffUuid returns a slice of all values from a that are not in b. Deprecated: use DiffSlice instead.
func ArrayDiffUuidRef ¶ added in v0.2.6
ArrayDiffUuidRef returns a slice of all values from a that are not in b. Deprecated: use DiffSlice instead.
func ArrayFillStr ¶ added in v0.0.2
func ArrayFilterAndJoinStr ¶ added in v0.0.2
ArrayFilterAndJoinStr returns a string of all values from a that are not empty, joined by sep.
func ArrayFilterFnStr ¶ added in v0.0.2
ArrayFilterFnStr returns a slice of all values from a that pass the filter function. Deprecated: use FilterSlice instead.
func ArrayFilterStr ¶ added in v0.0.2
ArrayFilterStr returns a slice of all values from a that are not empty.
func ArrayIncludesInt ¶ added in v0.0.2
ArrayIncludesInt returns true if the slice contains the value. Deprecated: use SliceIncludes instead.
func ArrayIncludesInt32 ¶ added in v0.0.2
ArrayIncludesInt32 returns true if the slice contains the value. Deprecated: use SliceIncludes instead.
func ArrayIncludesStr ¶ added in v0.0.2
ArrayIncludesStr returns true if the slice contains the value. Deprecated: use SliceIncludes instead.
func ArrayIncludesUUID ¶ added in v0.0.2
ArrayIncludesUUID returns true if the slice contains the value. Deprecated: use SliceIncludes instead.
func ArrayMapStr ¶ added in v0.0.2
ArrayMapStr returns a slice of all values from a mapped by fn(). Deprecated: use MapSlice instead.
func BoolFromSqlTinyInt ¶ added in v0.0.2
func BoolRef ¶ added in v0.0.2
BoolRef returns a fresh pointer for the value. Deprecated: use ToPtr instead.
func CliAskPassword ¶
func CliAskRequired ¶
func CliConfirm ¶
func DecimalFromRef ¶ added in v0.13.5
DecimalFromRef returns the value of the pointer, or the zero decimal if nil.
func DecimalRef ¶ added in v0.1.3
DecimalRef returns a fresh pointer for the value. Deprecated: use ToPtr instead.
func DecimalRefFromSql ¶ added in v0.2.0
func DecimalRefFromSql(v decimal.NullDecimal) *decimal.Decimal
DecimalRefFromSql will return nil for a 'null' SQL value.
func DerefPtrSlice ¶ added in v0.15.1
func DerefPtrSlice[T any](s []*T) []T
DerefPtrSlice converts a slice of pointers to a slice of values.
func DerefPtrSliceSlice ¶ added in v0.15.1
func DerefPtrSliceSlice[T any](s [][]*T) [][]T
DerefPtrSliceSlice converts a slice of slices of pointers to a slice of slices of values.
func DiffSlice ¶ added in v0.15.1
func DiffSlice[T comparable](a []T, b []T) []T
DiffSlice returns a slice of all values from a that are not in b.
func FilterSlice ¶ added in v0.15.1
FilterSlice returns a slice of all values from s that pass the filter function.
func FormatDate ¶ added in v0.0.2
FormatDate supports ordinal days.
func GenerateRandomKey ¶ added in v0.0.2
func GenerateRandomString ¶ added in v0.0.2
func GqlTimeRefSql ¶ added in v0.0.2
func IfThenElse ¶ added in v0.15.1
IfThenElse is a ternary helper function.
func Int32FromRef ¶ added in v0.13.5
Int32FromRef returns the value of the pointer, or 0 if nil.
func Int32MustParse ¶ added in v0.0.2
func Int32Ref ¶ added in v0.0.2
Int32Ref returns a fresh pointer for the value. Deprecated: use ToPtr instead.
func Int64FromRef ¶ added in v0.13.5
Int64FromRef returns the value of the pointer, or 0 if nil.
func Int64MustParse ¶ added in v0.0.2
func Int64Ref ¶ added in v0.0.2
Int64Ref returns a fresh pointer for the value. Deprecated: use ToPtr instead.
func IntArray2StrArray ¶ added in v0.0.8
func IntFromRef ¶ added in v0.13.5
IntFromRef returns the value of the pointer, or 0 if nil.
func IntRef ¶ added in v0.0.2
IntRef returns a fresh pointer for the value. Deprecated: use ToPtr instead.
func IntRefFromSql ¶ added in v0.2.0
IntRefFromSql will return nil for a 'null' SQL value.
func JoinIntArray ¶ added in v0.0.8
func NewDefaultLogger ¶
func PrintErrWithStack ¶
func PrintErrWithStack(err error)
func RenderTemplatePlain ¶ added in v0.0.2
func ScreamingSnakeCaseToHuman ¶ added in v0.15.1
ScreamingSnakeCaseToHuman converts HUMAN_READABLE to 'human readable'.
func SendSlackWebhook ¶ added in v0.6.4
func SendSlackWebhook(ctx context.Context, webhookUrl string, message SlackMessagePayload) error
func SliceIncludes ¶ added in v0.15.1
func SliceIncludes[T comparable](s []T, v T) bool
SliceIncludes returns true if the slice contains the value.
func SliceToPtrSlice ¶ added in v0.15.1
func SliceToPtrSlice[T any](s []T) []*T
SliceToPtrSlice converts a slice of values to a slice of pointers.
func SqlNullDecimalRef ¶ added in v0.2.0
func SqlNullDecimalRef(v *decimal.Decimal) decimal.NullDecimal
SqlNullDecimalRef will return a sql 'null' value if the pointer is nil.
func SqlNullInt32 ¶ added in v0.0.2
SqlNullInt32 will return a sql 'null' value if the value is 0.
func SqlNullIntRef ¶ added in v0.1.3
SqlNullIntRef will return a sql 'null' value if the pointer is nil.
func SqlNullStr ¶ added in v0.0.2
func SqlNullStr(v string) sql.NullString
SqlNullStr will return a sql 'null' value if the string is empty.
func SqlNullStrRef ¶ added in v0.0.2
func SqlNullStrRef(v *string) sql.NullString
SqlNullStrRef will return a sql 'null' value if the pointer is nil.
func SqlNullTime ¶ added in v0.0.2
SqlNullTime will return a sql 'null' value if the time is 0.
func SqlNullTimeRef ¶ added in v0.2.0
SqlNullTimeRef will return a sql 'null' value if the pointer is nil.
func SqlNullUuid ¶ added in v0.1.5
SqlNullUuid will return a sql 'null' value if the uuid is empty.
func SqlNullUuidRef ¶ added in v0.1.5
SqlNullUuidRef will return a sql 'null' value if the pointer is nil.
func SqlTimeToStrRef ¶ added in v0.0.2
func SqlTinyIntFromBool ¶ added in v0.0.2
func StrFromRef ¶ added in v0.0.2
StrFromRef returns the value of the pointer, or "" if nil.
func StrNilIfEmpty ¶ added in v0.2.4
StrNilIfEmpty returns nil if the string is empty.
func StrRef ¶ added in v0.0.2
StrRef returns a fresh pointer for the value. Deprecated: use ToPtr instead.
func StrRefFromSql ¶ added in v0.2.0
func StrRefFromSql(v sql.NullString) *string
StrRefFromSql will return nil for a 'null' SQL value.
func StrSliceToStrRefSlice ¶ added in v0.0.2
func TimeFromRef ¶ added in v0.13.5
TimeFromRef returns the value of the pointer, or the zero time if nil.
func TimeRef ¶ added in v0.0.2
TimeRef returns a fresh pointer for the value. Deprecated: use ToPtr instead.
func TimeRefFromGqlTimeRef ¶ added in v0.0.2
func TimeRefFromSql ¶ added in v0.2.0
TimeRefFromSql will return nil for a 'null' SQL value.
func ToPtr ¶ added in v0.15.1
func ToPtr[T any](v T) *T
ToPtr returns a fresh pointer for the value.
func TruncateStr ¶ added in v0.6.7
TruncateStr multibyte/UTF-8 safe truncate to a maximum number of characters.
func TruncateStrBytes ¶ added in v0.6.7
TruncateStrBytes multibyte/UTF-8 safe truncate to a maximum number of bytes.
Types ¶
type ClientError ¶ added in v0.0.6
type ClientError struct {
// contains filtered or unexported fields
}
ClientError represents an error that should be displayed to the user.
func NewClientError ¶ added in v0.0.6
func NewClientError(code string, message string, err error) *ClientError
func (*ClientError) Error ¶ added in v0.0.6
func (err *ClientError) Error() string
func (*ClientError) GqlErrorCode ¶ added in v0.0.6
func (err *ClientError) GqlErrorCode() string
func (*ClientError) StackTrace ¶ added in v0.0.6
func (err *ClientError) StackTrace() errors.StackTrace
func (*ClientError) Unwrap ¶ added in v0.0.6
func (err *ClientError) Unwrap() error
type ErrAndPanicGroup ¶ added in v0.15.1
type ErrAndPanicGroup struct {
// contains filtered or unexported fields
}
func NewErrAndPanicGroup ¶ added in v0.15.1
func NewErrAndPanicGroup() *ErrAndPanicGroup
func NewErrAndPanicGroupWithContext ¶ added in v0.15.1
func NewErrAndPanicGroupWithContext(ctx context.Context) (*ErrAndPanicGroup, context.Context)
func (*ErrAndPanicGroup) Go ¶ added in v0.15.1
func (g *ErrAndPanicGroup) Go(fn func() error)
func (*ErrAndPanicGroup) Wait ¶ added in v0.15.1
func (g *ErrAndPanicGroup) Wait() error
type SlackMessagePayload ¶ added in v0.6.4
type SlackWebhookClient ¶ added in v0.6.4
type SlackWebhookClient struct {
// contains filtered or unexported fields
}
func NewSlackWebhookClientFromEnv ¶ added in v0.6.4
func NewSlackWebhookClientFromEnv(log zerolog.Logger) *SlackWebhookClient
func (*SlackWebhookClient) Send ¶ added in v0.6.4
func (s *SlackWebhookClient) Send(ctx context.Context, message SlackMessagePayload)