helper

package
v0.1.438 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForNil

func CheckForNil(params ...any) error

CheckForNil checks if any of the given parameters is nil.

func CheckPointerToStruct

func CheckPointerToStruct(v any) error

CheckPointerToStruct checks if the provided value is a pointer to a struct.

func Deref

func Deref(v reflect.Value) reflect.Value

Deref dereferences a pointer value recursively.

func EarlyReturn added in v0.1.416

func EarlyReturn(ctx context.Context, e contract.EnvironmentOperator) (bool, error)

EarlyReturn returns true if the current execution environment is a local, development or staging environment.

func IsCI added in v0.1.289

func IsCI() bool

IsCI returns true if the current execution environment is a CI pipeline.

func ParseURL added in v0.1.119

func ParseURL(raw string) *url.URL

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

func RandomCode(length int) string

RandomCode returns a random numeric string of the specified length.

func RangeString added in v0.1.346

func RangeString(low, high int) []string

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 StructToMap added in v0.1.254

func StructToMap(v reflect.Value) map[string]any

StructToMap converts a struct to a map[string]any using reflection.

Types

type RetryOptions

type RetryOptions struct {
	MaxRetries uint
	RetryDelay time.Duration
}

Jump to

Keyboard shortcuts

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