utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildQueryParams added in v1.0.0

func BuildQueryParams(key string, values []string) string

BuildQueryParams builds a query string with repeated keys for each value. Example: BuildQueryParams("appName", []string{"foo", "bar"}) returns "appName=foo&appName=bar"

func CamelcaseToPascalCase added in v0.1.1

func CamelcaseToPascalCase(s string) string

CamelcaseToPascalCase converts a camelCase string to PascalCase.

func ConnectionURLBuilder

func ConnectionURLBuilder(n string) (string, error)

ConnectionURLBuilder func for building URL connection.

func Decrypt added in v0.1.0

func Decrypt(key, ciphertext string) (string, error)

Decrypt decrypts the given ciphertext using the provided key.

func Encrypt added in v0.1.0

func Encrypt(key, plaintext string) (string, error)

Encrypt encrypts the given plaintext using the provided key.

func ErrorHandler

func ErrorHandler(c fiber.Ctx, err error) error

ErrorHandler is a custom error handler for Fiber.

func ExtractExtensionFromBase64 added in v1.0.0

func ExtractExtensionFromBase64(base64String string) (string, error)

ExtractExtensionFromBase64 extracts the file extension from a base64 string.

func IsBase64 added in v1.0.0

func IsBase64(base64String string) bool

IsBase64 checks if a string is a valid base64 encoded string.

func JoinMapBool added in v1.0.0

func JoinMapBool(m map[string]bool, sep string) string

JoinMapBool joins a map of string keys and boolean values into a single string.

func NewNull added in v1.0.0

func NewNull[T any](value *T) sql.Null[T]

NewNull creates a sql.Null[T] from an pointer.

func NewNullBool added in v1.0.0

func NewNullBool(value *bool) sql.NullBool

NewNullBool creates a sql.NullBool from a bool pointer.

func NewNullByte added in v1.0.0

func NewNullByte(value *byte) sql.NullByte

NewNullByte creates a sql.NullByte from a byte pointer.

func NewNullFloat64 added in v1.0.0

func NewNullFloat64(value *float64) sql.NullFloat64

NewNullFloat64 creates a sql.NullFloat64 from a float64 pointer.

func NewNullInt16 added in v1.0.0

func NewNullInt16(value *int16) sql.NullInt16

NewNullInt16 creates a sql.NullInt16 from a int16 pointer.

func NewNullInt32 added in v1.0.0

func NewNullInt32(value *int32) sql.NullInt32

NewNullInt32 creates a sql.NullInt32 from an int32 pointer.

func NewNullInt64 added in v1.0.0

func NewNullInt64(value *int64) sql.NullInt64

NewNullInt64 creates a sql.NullInt64 from an int64 pointer.

func NewNullString added in v1.0.0

func NewNullString(value *string) sql.NullString

NewNullString creates a sql.NullString from a string pointer.

func NewNullTime added in v1.0.0

func NewNullTime(value *time.Time) sql.NullTime

NewNullTime creates a sql.NullTime from a time pointer.

func NewValidator

func NewValidator() *validator.Validate

NewValidator func for create a new validator for model fields.

validate := utils.NewValidator()
if err := validate.Struct(object); err != nil { }

func PascalCaseToCamelcase added in v0.0.5

func PascalCaseToCamelcase(s string) string

PascalCaseToCamelcase converts a PascalCase string to camelCase.

func PtrFromNull added in v1.0.0

func PtrFromNull[T any](v sql.Null[T]) *T

PtrFromNull creates a pointer from sql.Null[T].

func PtrFromNullBool added in v1.0.0

func PtrFromNullBool(v sql.NullBool) *bool

PtrFromNullBool creates a bool pointer from sql.NullBool.

func PtrFromNullByte added in v1.0.0

func PtrFromNullByte(v sql.NullByte) *byte

PtrFromNullByte creates a byte pointer from sql.NullByte.

func PtrFromNullFloat64 added in v1.0.0

func PtrFromNullFloat64(v sql.NullFloat64) *float64

PtrFromNullFloat64 creates a float64 pointer from sql.NullFloat64.

func PtrFromNullInt16 added in v1.0.0

func PtrFromNullInt16(v sql.NullInt16) *int16

PtrFromNullInt16 creates an int16 pointer from sql.NullInt16.

func PtrFromNullInt32 added in v1.0.0

func PtrFromNullInt32(v sql.NullInt32) *int32

PtrFromNullInt32 creates an int32 pointer from sql.NullInt32.

func PtrFromNullInt64 added in v1.0.0

func PtrFromNullInt64(v sql.NullInt64) *int64

PtrFromNullInt64 creates an int64 pointer from sql.NullInt64.

func PtrFromNullString added in v1.0.0

func PtrFromNullString(v sql.NullString) *string

PtrFromNullString creates a string pointer from sql.NullString.

func PtrFromNullTime added in v1.0.0

func PtrFromNullTime(v sql.NullTime) *time.Time

PtrFromNullTime creates a time pointer from sql.NullTime.

func StartServer

func StartServer(a *fiber.App)

StartServer func for starting a simple server.

func StartServerWithConfig added in v1.0.0

func StartServerWithConfig(a *fiber.App, cfg ServerConfig, deps ServerDeps)

StartServerWithConfig starts Fiber with explicit config.

func StartServerWithGracefulShutdown

func StartServerWithGracefulShutdown(a *fiber.App)

StartServerWithGracefulShutdown function for starting server with a graceful shutdown.

func StartServerWithGracefulShutdownConfig added in v1.0.0

func StartServerWithGracefulShutdownConfig(a *fiber.App, cfg ServerConfig, deps ServerDeps)

StartServerWithGracefulShutdownConfig starts Fiber with graceful shutdown using explicit config.

func StringToUint added in v0.0.5

func StringToUint(s string) (uint, error)

StringToUint function to convert string to uint.

func URLEncode added in v1.0.0

func URLEncode(s string) string

URLEncode converts an arbitrary string into an ASCII-only, URL-safe slug. Rules: - Trim leading/trailing whitespace; - Lowercase ASCII only; - Strip diacritics by normalizing to NFD and removing combining marks; - Replace any run of non-ASCII alphanumeric characters (including spaces/punctuation) with a single '-'; - Collapse repeated '-' and trim '-' from both ends.

func UintOrZero added in v1.0.0

func UintOrZero(value *uint) uint

UintOrZero func for return uint value or zero if pointer is nil.

func ValidatorErrors

func ValidatorErrors(err error) map[string]string

ValidatorErrors func for show validation errors for each invalid fields.

Types

type ServerConfig added in v1.0.0

type ServerConfig struct {
	Address string
}

ServerConfig defines runtime settings for Fiber server startup.

func ServerConfigFromEnv added in v1.0.0

func ServerConfigFromEnv() (ServerConfig, error)

ServerConfigFromEnv loads Fiber server config from environment variables.

type ServerDeps added in v1.0.0

type ServerDeps struct {
	Listen       func(a *fiber.App, addr string) error
	Shutdown     func(a *fiber.App) error
	NotifySignal func(c chan<- os.Signal, sig ...os.Signal)
}

ServerDeps defines startup dependencies to keep behavior explicit and testable.

func DefaultServerDeps added in v1.0.0

func DefaultServerDeps() ServerDeps

DefaultServerDeps returns production defaults for server startup dependencies.

Jump to

Keyboard shortcuts

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