Documentation
¶
Index ¶
- func CheckForNil(params ...any) error
- func CheckPointerToStruct(v any) error
- func ClientEmail(ctx context.Context, u contract.Unmarshaler, b []byte) (string, error)
- func Deref(v reflect.Value) reflect.Value
- func EarlyReturn(ctx context.Context, e contract.EnvironmentOperator) (bool, error)
- func ErrorOrNil(err error) string
- func FromPointers[T any](in []*T) []T
- func IsCI() bool
- func IsUTC(d time.Time) bool
- func KeyBytes(ctx context.Context, u contract.Unmarshaler, b []byte) ([]byte, error)
- func ParseURL(raw string) *url.URL
- func Point[T any](x T) *T
- func PrettyJSON(ctx context.Context, m contract.Marshaler, u contract.Unmarshaler, r io.Reader) ([]byte, error)
- func RandomCode(length int) string
- func RangeString(low, high int) []string
- func Retry(opts RetryOptions, f func() error) error
- func SanitizeFilename(n string) string
- func SplitMime(mimeType string) string
- func StructToMap(v reflect.Value) map[string]any
- func ToPointers[T any](in []T) []*T
- type RetryOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckForNil ¶
CheckForNil checks if any of the given parameters is nil.
func CheckPointerToStruct ¶
CheckPointerToStruct checks if the provided value is a pointer to a struct.
func ClientEmail ¶ added in v0.1.479
ClientEmail returns the client email from the service account.
func EarlyReturn ¶ added in v0.1.416
EarlyReturn returns true if the current execution environment is a local, development or staging environment.
func ErrorOrNil ¶ added in v0.1.583
ErrorOrNil returns the error message if not nil.
func FromPointers ¶ added in v0.1.471
func FromPointers[T any](in []*T) []T
FromPointers returns a slice of values from the given slice of pointers.
func IsCI ¶ added in v0.1.289
func IsCI() bool
IsCI returns true if the current execution environment is a CI pipeline.
func KeyBytes ¶ added in v0.1.479
KeyBytes returns the private key as bytes from the service account.
func ParseURL ¶ added in v0.1.119
ParseURL parses a raw string into a *url.URL. Returns a non-nil empty *url.URL on failure.
func Point ¶ added in v0.1.425
func Point[T any](x T) *T
Point returns a pointer to the given value.
func PrettyJSON ¶ added in v0.1.297
func PrettyJSON(ctx context.Context, m contract.Marshaler, u contract.Unmarshaler, r io.Reader) ([]byte, error)
PrettyJSON pretty-prints a JSON stream using default indentation.
func RandomCode ¶ added in v0.1.424
RandomCode returns a random numeric string of the specified length.
func RangeString ¶ added in v0.1.346
RangeString returns a slice of stringified integers between low and high (inclusive).
func Retry ¶
func Retry(opts RetryOptions, f func() error) error
Retry executes the provided function f at least once, retrying up to MaxRetries times if it fails. If MaxRetries is set to 0, the function will still run once. A delay is applied between retries. Returns nil if f succeeds within the allowed attempts; otherwise, returns the last encountered error.
func SanitizeFilename ¶ added in v0.1.497
SanitizeFilename removes unsafe characters from a filename.
func SplitMime ¶ added in v0.1.498
SplitMime returns the primary MIME prefix category from the given type.
func StructToMap ¶ added in v0.1.254
StructToMap converts a struct to a map[string]any using reflection.
func ToPointers ¶ added in v0.1.471
func ToPointers[T any](in []T) []*T
ToPointers returns a slice of pointers to the given slice of values.