Documentation
¶
Index ¶
- func CamelToSnake(s string) string
- func Capitalize(s string) string
- func ContainsAny(s string, substrings []string) bool
- func FormatAmount(amount float64, currency string) string
- func FormatAmountWithSeparators(amount float64, currency string) string
- func FormatFileSize(size int64) string
- func FromJSON(jsonStr string, v interface{}) error
- func GenerateReference(prefix string) string
- func GenerateSalt(length int) string
- func GenerateTransactionID(prefix string) string
- func GetMapBool(m map[string]interface{}, key string) bool
- func GetMapFloat(m map[string]interface{}, key string) float64
- func GetMapInt(m map[string]interface{}, key string) int
- func GetMapString(m map[string]interface{}, key string) string
- func GetMapValue(m map[string]interface{}, key string, defaultValue interface{}) interface{}
- func Hash(input string) string
- func HashWithSalt(input, salt string) string
- func IsAlphaNumeric(s string) bool
- func IsNumeric(s string) bool
- func IsValidUUID(uuid string) bool
- func MapKeys(m map[string]interface{}) []string
- func ParseAmount(amountStr string) (float64, error)
- func ParseDuration(duration string, fallback time.Duration) time.Duration
- func SanitizeString(input string) string
- func SliceContains(slice []string, item string) bool
- func SliceUnique(slice []string) []string
- func SnakeToCamel(s string) string
- func TimeElapsed(start time.Time) string
- func ToJSON(v interface{}) string
- type DefaultHTTPClient
- type HTTPClient
- type HTTPConfig
- type HTTPRequest
- type HTTPResponse
- type RetryConfig
- type RetryExecutor
- type RetryablePaymentFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelToSnake ¶
CamelToSnake converts camelCase to snake_case
func ContainsAny ¶
ContainsAny checks if string contains any of the substrings
func FormatAmount ¶
FormatAmount formats monetary amount for display
func FormatAmountWithSeparators ¶
FormatAmountWithSeparators formats amount with thousands separators
func FormatFileSize ¶
FormatFileSize formats file size in human readable format
func GenerateReference ¶
func GenerateTransactionID ¶
func GetMapBool ¶
GetMapBool safely gets bool value from map
func GetMapFloat ¶
GetMapFloat safely gets float64 value from map
func GetMapString ¶
GetMapString safely gets string value from map
func GetMapValue ¶
GetMapValue safely gets value from map with default
func HashWithSalt ¶
HashWithSalt generates SHA256 hash with salt
func IsAlphaNumeric ¶
IsAlphaNumeric checks if string contains only alphanumeric characters
func ParseAmount ¶
ParseAmount parses amount string to float64
func ParseDuration ¶
ParseDuration parses duration with fallback
func SanitizeString ¶
SanitizeString removes or replaces potentially dangerous characters
func SliceContains ¶
func SliceUnique ¶
SliceUnique removes duplicates from slice
func SnakeToCamel ¶
SnakeToCamel converts snake_case to camelCase
func TimeElapsed ¶
TimeElapsed returns human readable time elapsed
Types ¶
type DefaultHTTPClient ¶
type DefaultHTTPClient struct {
// contains filtered or unexported fields
}
DefaultHTTPClient implements HTTPClient using Go's http.Client
func (*DefaultHTTPClient) Do ¶
func (c *DefaultHTTPClient) Do(request *HTTPRequest) (*HTTPResponse, error)
Do executes an HTTP request
type HTTPClient ¶
type HTTPClient interface {
Do(req *HTTPRequest) (*HTTPResponse, error)
}
HTTPClient defines HTTP client interface
func NewHTTPClient ¶
func NewHTTPClient(config HTTPConfig) HTTPClient
NewHTTPClient creates a new HTTP client
type HTTPConfig ¶
type HTTPConfig struct {
Timeout time.Duration
MaxIdleConns int
MaxConnsPerHost int
UserAgent string
}
HTTPConfig represents HTTP client configuration
type HTTPRequest ¶
type HTTPRequest struct {
Method string
URL string
Headers map[string]string
Body []byte
Timeout time.Duration
}
HTTPRequest represents an HTTP request
type HTTPResponse ¶
HTTPResponse represents an HTTP response
type RetryConfig ¶
type RetryConfig struct {
MaxAttempts int `json:"max_attempts"`
InitialDelay time.Duration `json:"initial_delay"`
MaxDelay time.Duration `json:"max_delay"`
Multiplier float64 `json:"multiplier"`
EnableJitter bool `json:"enable_jitter"`
}
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig returns default retry configuration
type RetryExecutor ¶
type RetryExecutor struct {
// contains filtered or unexported fields
}
RetryExecutor handles retry logic
func NewRetryExecutor ¶
func NewRetryExecutor(config RetryConfig) *RetryExecutor
NewRetryExecutor creates a new retry executor
func (*RetryExecutor) ExecutePayment ¶
func (re *RetryExecutor) ExecutePayment(ctx context.Context, fn RetryablePaymentFunc) (*types.PaymentResponse, error)
ExecutePayment executes a payment function with retry logic
type RetryablePaymentFunc ¶
type RetryablePaymentFunc func() (*types.PaymentResponse, error)
RetryablePaymentFunc represents a payment function that can be retried