Documentation
¶
Overview ¶
Package util provides general-purpose utility functions.
Package util provides general-purpose utility functions including URL slug generation and validation with Unicode normalization support.
Index ¶
- func IsValidAlias(s string) bool
- func IsValidSlug(s string) bool
- func NullInt64FromPtr(ptr *int64) sql.NullInt64
- func NullInt64FromValue(val int64) sql.NullInt64
- func NullStringFromPtr(ptr *string) sql.NullString
- func NullStringFromValue(s string) sql.NullString
- func ParseNullInt64(s string) sql.NullInt64
- func ParseNullInt64Positive(s string) sql.NullInt64
- func Slugify(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidAlias ¶
IsValidAlias checks if a string is a valid alias format. Aliases can contain path segments separated by forward slashes (e.g., "blog/post/55"). Each segment must be a valid slug: lowercase letters, numbers, and hyphens.
func IsValidSlug ¶
IsValidSlug checks if a string is a valid slug format.
func NullInt64FromPtr ¶
NullInt64FromPtr converts a pointer to int64 into sql.NullInt64. Returns a valid NullInt64 if the pointer is non-nil, otherwise returns an invalid one.
func NullInt64FromValue ¶
NullInt64FromValue creates a valid sql.NullInt64 from an int64 value.
func NullStringFromPtr ¶
func NullStringFromPtr(ptr *string) sql.NullString
NullStringFromPtr converts a pointer to string into sql.NullString. Returns a valid NullString if the pointer is non-nil, otherwise returns an invalid one.
func NullStringFromValue ¶
func NullStringFromValue(s string) sql.NullString
NullStringFromValue creates a sql.NullString from a string value. Returns a valid NullString if the string is non-empty, otherwise returns an invalid one.
func ParseNullInt64 ¶
ParseNullInt64 parses a string into sql.NullInt64. Returns an invalid NullInt64 if the string is empty, "0", or cannot be parsed.
func ParseNullInt64Positive ¶
ParseNullInt64Positive parses a string into sql.NullInt64, requiring positive values. Returns an invalid NullInt64 if the string is empty, cannot be parsed, or value is <= 0.
Types ¶
This section is empty.