support

package
v0.0.0-20260608 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextKeyRequestID is the context key for the request ID.
	ContextKeyRequestID contextKey = "request_id"
	// ContextKeyUserID is the context key for the user ID.
	ContextKeyUserID contextKey = "user_id"
	// ContextKeyTenantID is the context key for the tenant ID.
	ContextKeyTenantID contextKey = "tenant_id"
	// ContextKeyLocale is the context key for the locale.
	ContextKeyLocale contextKey = "locale"
	// ContextKeyChannel is the context key for the channel (web, api, cli, etc.).
	ContextKeyChannel contextKey = "channel"
)

Variables

This section is empty.

Functions

func Abs

func Abs(n float64) float64

Abs returns the absolute value

func Ago

func Ago(t time.Time) string

Ago returns a human-readable time difference

func ArrayGet

func ArrayGet(data []any, key string) any

ArrayGet gets a value from an array using dot notation

func ArraySet

func ArraySet(data []any, key string, value any) []any

ArraySet sets a value in an array using dot notation

func Average

func Average[T int | float32 | float64](data []T) float64

Average returns the average of items (for numeric types)

func Bytes

func Bytes(n int) string

Bytes converts a number to bytes

func Camel

func Camel(s string) string

Camel converts a string to camelCase

func Ceil

func Ceil(n float64) float64

Ceil rounds a number up

func Chunk

func Chunk[T any](data []T, size int) [][]T

Chunk splits a slice into chunks

func Clamp

func Clamp(n, minVal, maxVal float64) float64

Clamp clamps a number between min and max

func Collect

func Collect[T any](fns ...func() T) []T

Collect collects results from concurrent operations.

func Contains

func Contains[T comparable](data []T, item T) bool

Contains checks if a slice contains an item

func ContainsAll

func ContainsAll[T comparable](data []T, items ...T) bool

ContainsAll checks if a slice contains all items

func ContainsAny

func ContainsAny[T comparable](data []T, items ...T) bool

ContainsAny checks if a slice contains any of the items

func ContextChannel

func ContextChannel(ctx context.Context) string

ContextChannel extracts the channel from the context.

func ContextLocale

func ContextLocale(ctx context.Context) string

ContextLocale extracts the locale from the context.

func ContextRequestID

func ContextRequestID(ctx context.Context) string

ContextRequestID extracts the request ID from the context.

func ContextTenantID

func ContextTenantID(ctx context.Context) any

ContextTenantID extracts the tenant ID from the context.

func ContextUserID

func ContextUserID(ctx context.Context) any

ContextUserID extracts the user ID from the context.

func ContextWithChannel

func ContextWithChannel(ctx context.Context, channel string) context.Context

ContextWithChannel adds a channel to the context.

func ContextWithLocale

func ContextWithLocale(ctx context.Context, locale string) context.Context

ContextWithLocale adds a locale to the context.

func ContextWithRequestID

func ContextWithRequestID(ctx context.Context, requestID string) context.Context

ContextWithRequestID adds a request ID to the context.

func ContextWithTenantID

func ContextWithTenantID(ctx context.Context, tenantID any) context.Context

ContextWithTenantID adds a tenant ID to the context.

func ContextWithUserID

func ContextWithUserID(ctx context.Context, userID any) context.Context

ContextWithUserID adds a user ID to the context.

func Currency

func Currency(n float64, symbol string) string

Currency formats a number as currency

func Diff

func Diff[T comparable](a, b []T) []T

Diff returns items in the first slice that are not in the second

func DotDelete

func DotDelete(data map[string]any, key string)

DotDelete deletes a key using dot notation

func DotFlatten

func DotFlatten(data map[string]any) map[string]any

DotFlatten flattens a nested map using dot notation

func DotGet

func DotGet(data map[string]any, key string) any

DotGet gets a value from a map using dot notation

func DotHas

func DotHas(data map[string]any, key string) bool

DotHas checks if a key exists using dot notation

func DotSet

func DotSet(data map[string]any, key string, value any)

DotSet sets a value in a map using dot notation

func DotUnflatten

func DotUnflatten(data map[string]any) map[string]any

DotUnflatten unflattens a map using dot notation

func Each

func Each[T any](data []T, callback func(T))

Each iterates over a slice

func EachWithIndex

func EachWithIndex[T any](data []T, callback func(int, T))

EachWithIndex iterates over a slice with index

func Filter

func Filter[T any](data []T, predicate func(T) bool) []T

Filter filters a slice based on a predicate

func Flatten

func Flatten[T any](slices [][]T) []T

Flatten flattens a slice of slices

func Floor

func Floor(n float64) float64

Floor rounds a number down

func GroupBy

func GroupBy[T any](data []T, key string) map[string][]T

GroupBy groups a slice of maps by a key

func Head[T any](data []T) (T, bool)

Head returns the first item

func Intersect

func Intersect[T comparable](a, b []T) []T

Intersect returns items that are in both slices

func Kebab

func Kebab(s string) string

Kebab converts a string to kebab-case

func Last

func Last[T any](data []T) (T, bool)

Last returns the last item

func LimitConcurrency

func LimitConcurrency(limit int, fns ...func())

LimitConcurrency limits the number of concurrent operations.

func LimitStr

func LimitStr(s string, length int, suffix string) string

Limit limits a string to a given length

func LimitWordsStr

func LimitWordsStr(s string, words int, suffix string) string

LimitWordsStr limits a string to a given number of words

func Map

func Map[T any, U any](data []T, mapper func(T) U) []U

Map transforms a slice using a mapper function

func Max

func Max[T int | float32 | float64 | string](data []T) (T, bool)

Max returns the maximum item (for ordered types)

func MaxFloat

func MaxFloat(a, b float64) float64

MaxFloat returns the maximum of two numbers

func Merge

func Merge[T any](slices ...[]T) []T

Merge merges multiple slices

func Min

func Min[T int | float32 | float64 | string](data []T) (T, bool)

Min returns the minimum item (for ordered types)

func MinFloat

func MinFloat(a, b float64) float64

MinFloat returns the minimum of two numbers

func Number

func Number(n float64) string

Number formats a number with commas

func NumberFormat

func NumberFormat(n float64, decimals int) string

NumberFormat formats a number with decimal places

func PadLeft

func PadLeft(s string, length int, pad string) string

PadLeft pads a string on the left

func PadRight

func PadRight(s string, length int, pad string) string

PadRight pads a string on the right

func Parallel

func Parallel(fns ...func())

Parallel runs multiple functions concurrently and waits for all to complete.

func Percentage

func Percentage(n float64) string

Percentage formats a number as percentage

func Pluck

func Pluck[T any, U any](data []T, key string, transform func(T) U) []U

Pluck extracts values from a slice of maps

func Plural

func Plural(s string) string

Plural converts a string to its plural form

func Random

func Random(length int) string

Random returns a random string of given length

func RandomAlpha

func RandomAlpha(length int) string

RandomAlpha returns a random alphabetic string

func RandomAlphanumeric

func RandomAlphanumeric(length int) string

RandomAlphanumeric returns a random alphanumeric string

func RandomNumeric

func RandomNumeric(length int) string

RandomNumeric returns a random numeric string

func Reduce

func Reduce[T any, U any](data []T, reducer func(U, T) U, initial U) U

Reduce reduces a slice to a single value

func Retry

func Retry(attempts int, fn func() error) error

Retry retries a function up to n times with exponential backoff.

func RetryWithDelay

func RetryWithDelay(attempts int, delayFn func(attempt int) int, fn func() error) error

RetryWithDelay retries a function with a specific delay between attempts.

func Reverse

func Reverse[T any](data []T) []T

Reverse reverses a slice

func Round

func Round(n float64, precision int) float64

Round rounds a number to a given precision

func Shuffle

func Shuffle[T any](data []T) []T

Shuffle shuffles a slice

func Singular

func Singular(s string) string

Singular converts a string to its singular form

func Skip

func Skip[T any](data []T, n int) []T

Skip returns all items except the first n

func Slug

func Slug(s string) string

Slug converts a string to a slug

func Snake

func Snake(s string) string

Snake converts a string to snake_case

func StrAfter

func StrAfter(s, delimiter string) string

StrAfter returns the substring after the first occurrence

func StrBefore

func StrBefore(s, delimiter string) string

StrBefore returns the substring before the first occurrence

func StrBetween

func StrBetween(s, start, end string) string

StrBetween returns the substring between two delimiters

func StrContains

func StrContains(s, substring string) bool

StrContains checks if a string contains a substring

func StrEndsWith

func StrEndsWith(s, suffix string) bool

StrEndsWith checks if a string ends with a suffix

func StrIsEmpty

func StrIsEmpty(s string) bool

StrIsEmpty checks if a string is empty

func StrIsNotEmpty

func StrIsNotEmpty(s string) bool

StrIsNotEmpty checks if a string is not empty

func StrJoin

func StrJoin(parts []string, delimiter string) string

StrJoin joins a slice of strings with a delimiter

func StrLength

func StrLength(s string) int

StrLength returns the length of a string

func StrRepeat

func StrRepeat(s string, n int) string

StrRepeat repeats a string n times

func StrReplace

func StrReplace(s, search, replace string) string

StrReplace replaces occurrences of a substring

func StrReverse

func StrReverse(s string) string

StrReverse reverses a string

func StrSplit

func StrSplit(s, delimiter string) []string

StrSplit splits a string by a delimiter

func StrStartsWith

func StrStartsWith(s, prefix string) bool

StrStartsWith checks if a string starts with a prefix

func StrToLower

func StrToLower(s string) string

StrToLower converts a string to lowercase

func StrToUpper

func StrToUpper(s string) string

StrToUpper converts a string to uppercase

func StrTrim

func StrTrim(s string) string

StrTrim trims whitespace from a string

func Studly

func Studly(s string) string

Studly converts a string to StudlyCase

func Sum

func Sum[T int | float32 | float64](data []T) T

Sum returns the sum of items (for numeric types)

func Tail

func Tail[T any](data []T) []T

Tail returns all items except the first

func Take

func Take[T any](data []T, n int) []T

Take returns the first n items

func Tap

func Tap[T any](value T, callback func(T)) T

Tappable provides tap-style method chaining. Usage:

tap(obj, func(o *MyStruct) {
    o.SetColor("red")
    o.SetSize(100)
})

func TitleStr

func TitleStr(s string) string

Title converts a string to title case

func Unique

func Unique[T comparable](data []T) []T

Unique returns unique values from a slice

func Until

func Until(t time.Time) string

Until returns a human-readable time until

func Uuid

func Uuid() string

Uuid generates a UUID v4

func WordsStr

func WordsStr(s string, words int) string

WordsStr returns the first n words of a string

Types

type Carbon

type Carbon struct {
	time.Time
}

Carbon is a fluent DateTime wrapper (Laravel Carbon equivalent).

func Create

func Create(year, month, day, hour, min, sec int) *Carbon

Create creates a Carbon instance from components.

func CreateFromDate

func CreateFromDate(year, month, day int) *Carbon

CreateFromDate creates a Carbon from date only.

func CreateFromTime

func CreateFromTime(hour, min, sec int) *Carbon

CreateFromTime creates a Carbon from time only.

func Now

func Now() *Carbon

Now returns the current time.

func Parse

func Parse(layout, value string) *Carbon

Parse parses a time string.

func ParseDate

func ParseDate(value string) *Carbon

ParseDate parses a date string in "2006-01-02" format.

func ParseTimestamp

func ParseTimestamp(timestamp int64) *Carbon

ParseTimestamp parses a Unix timestamp.

func Tomorrow

func Tomorrow() *Carbon

Tomorrow returns tomorrow's date.

func Yesterday

func Yesterday() *Carbon

Yesterday returns yesterday's date.

func (*Carbon) AddDays

func (c *Carbon) AddDays(days int) *Carbon

AddDays adds days to the date.

func (*Carbon) AddHours

func (c *Carbon) AddHours(hours int) *Carbon

AddHours adds hours to the date.

func (*Carbon) AddMinutes

func (c *Carbon) AddMinutes(minutes int) *Carbon

AddMinutes adds minutes to the date.

func (*Carbon) AddMonths

func (c *Carbon) AddMonths(months int) *Carbon

AddMonths adds months to the date.

func (*Carbon) AddSeconds

func (c *Carbon) AddSeconds(seconds int) *Carbon

AddSeconds adds seconds to the date.

func (*Carbon) AddYears

func (c *Carbon) AddYears(years int) *Carbon

AddYears adds years to the date.

func (*Carbon) Between

func (c *Carbon) Between(start, end *Carbon) bool

Between checks if the date is between two dates.

func (*Carbon) Clamp

func (c *Carbon) Clamp(min, max *Carbon) *Carbon

Clamp ensures the date is between min and max.

func (*Carbon) Copy

func (c *Carbon) Copy() *Carbon

Copy creates a copy of the Carbon instance.

func (*Carbon) DayOfWeek

func (c *Carbon) DayOfWeek() int

DayOfWeek returns the day of the week (1=Monday, 7=Sunday).

func (*Carbon) DayOfYear

func (c *Carbon) DayOfYear() int

DayOfYear returns the day of the year.

func (*Carbon) DaysInMonth

func (c *Carbon) DaysInMonth() int

DaysInMonth returns the number of days in the month.

func (*Carbon) DaysInYear

func (c *Carbon) DaysInYear() int

DaysInYear returns the number of days in the year.

func (*Carbon) DiffForHumans

func (c *Carbon) DiffForHumans(other *Carbon) string

DiffForHumans returns a human-readable difference (e.g., "2 hours ago").

func (*Carbon) DiffInDays

func (c *Carbon) DiffInDays(other *Carbon) int

DiffInDays returns the difference in days.

func (*Carbon) DiffInHours

func (c *Carbon) DiffInHours(other *Carbon) int64

DiffInHours returns the difference in hours.

func (*Carbon) DiffInMinutes

func (c *Carbon) DiffInMinutes(other *Carbon) int64

DiffInMinutes returns the difference in minutes.

func (*Carbon) DiffInSeconds

func (c *Carbon) DiffInSeconds(other *Carbon) int64

DiffInSeconds returns the difference in seconds.

func (*Carbon) EndOfDay

func (c *Carbon) EndOfDay() *Carbon

EndOfDay sets the time to 23:59:59.

func (*Carbon) EndOfMonth

func (c *Carbon) EndOfMonth() *Carbon

EndOfMonth sets the day to the last day of the month.

func (*Carbon) EndOfWeek

func (c *Carbon) EndOfWeek() *Carbon

EndOfWeek sets to the end of the week (Sunday).

func (*Carbon) EndOfYear

func (c *Carbon) EndOfYear() *Carbon

EndOfYear sets to December 31, 23:59:59.

func (*Carbon) Format

func (c *Carbon) Format(layout string) string

Format formats the date using Go's layout format.

func (*Carbon) IsBirthday

func (c *Carbon) IsBirthday(other *Carbon) bool

IsBirthday checks if the date is the birthday (ignoring year).

func (*Carbon) IsCurrentMonth

func (c *Carbon) IsCurrentMonth() bool

IsCurrentMonth checks if the date is in the current month.

func (*Carbon) IsCurrentYear

func (c *Carbon) IsCurrentYear() bool

IsCurrentYear checks if the date is the current year.

func (*Carbon) IsFuture

func (c *Carbon) IsFuture() bool

IsFuture checks if the date is in the future.

func (*Carbon) IsLastMonth

func (c *Carbon) IsLastMonth() bool

IsLastMonth checks if the date is in the last month.

func (*Carbon) IsLastYear

func (c *Carbon) IsLastYear() bool

IsLastYear checks if the date is last year.

func (*Carbon) IsLeapYear

func (c *Carbon) IsLeapYear() bool

IsLeapYear checks if the year is a leap year.

func (*Carbon) IsNextMonth

func (c *Carbon) IsNextMonth() bool

IsNextMonth checks if the date is in the next month.

func (*Carbon) IsNextYear

func (c *Carbon) IsNextYear() bool

IsNextYear checks if the date is next year.

func (*Carbon) IsPast

func (c *Carbon) IsPast() bool

IsPast checks if the date is in the past.

func (*Carbon) IsSameDay

func (c *Carbon) IsSameDay(other *Carbon) bool

IsSameDay checks if two dates are the same day.

func (*Carbon) IsSameMonth

func (c *Carbon) IsSameMonth(other *Carbon) bool

IsSameMonth checks if two dates are the same month.

func (*Carbon) IsSameYear

func (c *Carbon) IsSameYear(other *Carbon) bool

IsSameYear checks if two dates are the same year.

func (*Carbon) IsToday

func (c *Carbon) IsToday() bool

IsToday checks if the date is today.

func (*Carbon) IsTomorrow

func (c *Carbon) IsTomorrow() bool

IsTomorrow checks if the date is tomorrow.

func (*Carbon) IsWeekday

func (c *Carbon) IsWeekday() bool

IsWeekday checks if the date is a weekday.

func (*Carbon) IsWeekend

func (c *Carbon) IsWeekend() bool

IsWeekend checks if the date is a weekend.

func (*Carbon) IsYesterday

func (c *Carbon) IsYesterday() bool

IsYesterday checks if the date was yesterday.

func (*Carbon) Quarter

func (c *Carbon) Quarter() int

Quarter returns the quarter of the year (1-4).

func (*Carbon) StartOfDay

func (c *Carbon) StartOfDay() *Carbon

StartOfDay sets the time to 00:00:00.

func (*Carbon) StartOfMonth

func (c *Carbon) StartOfMonth() *Carbon

StartOfMonth sets the day to 1 and time to 00:00:00.

func (*Carbon) StartOfWeek

func (c *Carbon) StartOfWeek() *Carbon

StartOfWeek sets to the start of the week (Monday).

func (*Carbon) StartOfYear

func (c *Carbon) StartOfYear() *Carbon

StartOfYear sets to January 1, 00:00:00.

func (*Carbon) SubDays

func (c *Carbon) SubDays(days int) *Carbon

SubDays subtracts days from the date.

func (*Carbon) SubHours

func (c *Carbon) SubHours(hours int) *Carbon

SubHours subtracts hours from the date.

func (*Carbon) SubMinutes

func (c *Carbon) SubMinutes(minutes int) *Carbon

SubMinutes subtracts minutes from the date.

func (*Carbon) SubMonths

func (c *Carbon) SubMonths(months int) *Carbon

SubMonths subtracts months from the date.

func (*Carbon) SubSeconds

func (c *Carbon) SubSeconds(seconds int) *Carbon

SubSeconds subtracts seconds from the date.

func (*Carbon) SubYears

func (c *Carbon) SubYears(years int) *Carbon

SubYears subtracts years from the date.

func (*Carbon) ToDateString

func (c *Carbon) ToDateString() string

ToDateString formats as "2006-01-02".

func (*Carbon) ToDateTimeString

func (c *Carbon) ToDateTimeString() string

ToDateTimeString formats as "2006-01-02 15:04:05".

func (*Carbon) ToDayDateTimeString

func (c *Carbon) ToDayDateTimeString() string

ToDayDateTimeString formats as "Mon, Jan 02, 2006 15:04:05".

func (*Carbon) ToFormattedDateString

func (c *Carbon) ToFormattedDateString() string

ToFormattedDateString formats as "Jan 02, 2006".

func (*Carbon) ToIso8601String

func (c *Carbon) ToIso8601String() string

ToIso8601String formats as ISO 8601.

func (*Carbon) ToRFC3339

func (c *Carbon) ToRFC3339() string

ToRFC3339 formats as RFC 3339.

func (*Carbon) ToTimeString

func (c *Carbon) ToTimeString() string

ToTimeString formats as "15:04:05".

func (*Carbon) ToTimezone

func (c *Carbon) ToTimezone(timezone string) *Carbon

ToTimezone converts the date to a specific timezone.

func (*Carbon) ToUnix

func (c *Carbon) ToUnix() int64

ToUnix returns the Unix timestamp.

func (*Carbon) WeekOfYear

func (c *Carbon) WeekOfYear() int

WeekOfYear returns the ISO week number.

type Concurrency

type Concurrency struct {
	// contains filtered or unexported fields
}

Concurrency provides helpers for concurrent operations.

func NewConcurrency

func NewConcurrency() *Concurrency

NewConcurrency creates a new Concurrency instance.

func (*Concurrency) Go

func (c *Concurrency) Go(fn func())

Go runs a function in a goroutine.

func (*Concurrency) Wait

func (c *Concurrency) Wait()

Wait blocks until all goroutines complete.

type Conditionable

type Conditionable[T any] struct {
	// contains filtered or unexported fields
}

Conditionable provides conditional method chaining. Usage:

obj.When(condition, func(o *MyStruct) {
    o.SetColor("red")
})

func NewConditionable

func NewConditionable[T any](value T) *Conditionable[T]

NewConditionable creates a new Conditionable.

func (*Conditionable[T]) Unless

func (c *Conditionable[T]) Unless(condition bool, callback func(T)) *Conditionable[T]

Unless executes the callback if the condition is false.

func (*Conditionable[T]) Value

func (c *Conditionable[T]) Value() T

Value returns the underlying value.

func (*Conditionable[T]) When

func (c *Conditionable[T]) When(condition bool, callback func(T)) *Conditionable[T]

When executes the callback if the condition is true.

type ContextPropagator

type ContextPropagator struct {
	// contains filtered or unexported fields
}

ContextPropagator manages context values across goroutines.

func NewContextPropagator

func NewContextPropagator() *ContextPropagator

NewContextPropagator creates a new context propagator.

func (*ContextPropagator) FromContext

func (cp *ContextPropagator) FromContext(ctx context.Context)

FromContext extracts values from a context into the propagator.

func (*ContextPropagator) Get

func (cp *ContextPropagator) Get(key contextKey) (any, bool)

Get gets a value from the propagator.

func (*ContextPropagator) Set

func (cp *ContextPropagator) Set(key contextKey, value any)

Set sets a value in the propagator.

func (*ContextPropagator) WithContext

func (cp *ContextPropagator) WithContext(ctx context.Context) context.Context

WithContext creates a new context with the propagator's values.

type Defer

type Defer struct {
	// contains filtered or unexported fields
}

Defer provides a deferred execution helper. The callback is registered and will be executed when Flush() is called.

func NewDefer

func NewDefer() *Defer

NewDefer creates a new Defer instance.

func (*Defer) Add

func (d *Defer) Add(fn func()) *Defer

Add registers a callback to be deferred.

func (*Defer) Flush

func (d *Defer) Flush()

Flush executes all deferred callbacks in LIFO order.

type Once

type Once[T any] struct {
	// contains filtered or unexported fields
}

Once provides a sync.Once-style helper for lazy initialization.

func NewOnce

func NewOnce[T any](fn func() T) *Once[T]

NewOnce creates a new Once instance.

func (*Once[T]) Get

func (o *Once[T]) Get() T

Get returns the value, executing the function only once.

type StringHelper

type StringHelper struct {
	// contains filtered or unexported fields
}

StringHelper provides string manipulation helpers

func Str

func Str(s string) *StringHelper

Str returns a string helper

func (*StringHelper) After

func (s *StringHelper) After(delimiter string) string

After returns the substring after the first occurrence of a given value

func (*StringHelper) AfterLast

func (s *StringHelper) AfterLast(delimiter string) string

AfterLast returns the substring after the last occurrence of a given value

func (*StringHelper) Base64Decode

func (s *StringHelper) Base64Decode() (string, error)

Base64Decode decodes the string from base64

func (*StringHelper) Base64Encode

func (s *StringHelper) Base64Encode() string

Base64Encode encodes the string to base64

func (*StringHelper) Before

func (s *StringHelper) Before(delimiter string) string

Before returns the substring before the first occurrence of a given value

func (*StringHelper) BeforeLast

func (s *StringHelper) BeforeLast(delimiter string) string

BeforeLast returns the substring before the last occurrence of a given value

func (*StringHelper) Between

func (s *StringHelper) Between(start, end string) string

Between returns the substring between two delimiters

func (*StringHelper) Camel

func (s *StringHelper) Camel() string

Camel converts the string to camelCase

func (*StringHelper) Contains

func (s *StringHelper) Contains(substring string) bool

Contains checks if the string contains a substring

func (*StringHelper) ContainsAll

func (s *StringHelper) ContainsAll(substrings []string) bool

ContainsAll checks if the string contains all substrings

func (*StringHelper) EndsWith

func (s *StringHelper) EndsWith(suffix string) bool

EndsWith checks if the string ends with a substring

func (*StringHelper) Hash

func (s *StringHelper) Hash() string

Hash generates a hash of the string (simple implementation)

func (*StringHelper) Is

func (s *StringHelper) Is(pattern string) bool

Is checks if the string matches a pattern

func (*StringHelper) IsAlpha

func (s *StringHelper) IsAlpha() bool

IsAlpha checks if the string contains only letters

func (*StringHelper) IsAlphaNumeric

func (s *StringHelper) IsAlphaNumeric() bool

IsAlphaNumeric checks if the string contains only letters and numbers

func (*StringHelper) IsEmail

func (s *StringHelper) IsEmail() bool

IsEmail checks if the string is an email

func (*StringHelper) IsEmpty

func (s *StringHelper) IsEmpty() bool

IsEmpty checks if the string is empty

func (*StringHelper) IsIP

func (s *StringHelper) IsIP() bool

IsIP checks if the string is an IP address

func (*StringHelper) IsJSON

func (s *StringHelper) IsJSON() bool

IsJSON checks if the string is valid JSON

func (*StringHelper) IsNotEmpty

func (s *StringHelper) IsNotEmpty() bool

IsNotEmpty checks if the string is not empty

func (*StringHelper) IsNumeric

func (s *StringHelper) IsNumeric() bool

IsNumeric checks if the string is numeric

func (*StringHelper) IsURL

func (s *StringHelper) IsURL() bool

IsURL checks if the string is a URL

func (*StringHelper) IsUUID

func (s *StringHelper) IsUUID() bool

IsUUID checks if the string is a UUID

func (*StringHelper) Kebab

func (s *StringHelper) Kebab() string

Kebab converts the string to kebab-case

func (*StringHelper) Length

func (s *StringHelper) Length() int

Length returns the length of the string

func (*StringHelper) Limit

func (s *StringHelper) Limit(limit int, suffix string) string

Limit limits the string to a given length

func (*StringHelper) LimitWords

func (s *StringHelper) LimitWords(words int, suffix string) string

LimitWords limits the string to a given number of words

func (*StringHelper) Lower

func (s *StringHelper) Lower() string

Lower converts the string to lowercase

func (*StringHelper) PadLeft

func (s *StringHelper) PadLeft(length int, pad string) string

PadLeft pads the string on the left to a given length

func (*StringHelper) PadRight

func (s *StringHelper) PadRight(length int, pad string) string

PadRight pads the string on the right to a given length

func (*StringHelper) Plural

func (s *StringHelper) Plural() string

Plural converts the string to its plural form (simple implementation)

func (*StringHelper) Repeat

func (s *StringHelper) Repeat(n int) string

Repeat repeats the string n times

func (*StringHelper) Replace

func (s *StringHelper) Replace(search, replace string) string

Replace replaces occurrences of a substring

func (*StringHelper) ReplaceFirst

func (s *StringHelper) ReplaceFirst(search, replace string) string

ReplaceFirst replaces the first occurrence of a substring

func (*StringHelper) ReplaceLast

func (s *StringHelper) ReplaceLast(search, replace string) string

ReplaceLast replaces the last occurrence of a substring

func (*StringHelper) Reverse

func (s *StringHelper) Reverse() string

Reverse reverses the string

func (*StringHelper) Singular

func (s *StringHelper) Singular() string

Singular converts the string to its singular form (simple implementation)

func (*StringHelper) Slug

func (s *StringHelper) Slug() string

Slug converts the string to a slug

func (*StringHelper) Snake

func (s *StringHelper) Snake() string

Snake converts the string to snake_case

func (*StringHelper) StartsWith

func (s *StringHelper) StartsWith(prefix string) bool

StartsWith checks if the string starts with a substring

func (*StringHelper) Studly

func (s *StringHelper) Studly() string

Studly converts the string to StudlyCase

func (*StringHelper) Title

func (s *StringHelper) Title() string

Title converts the string to title case

func (*StringHelper) Upper

func (s *StringHelper) Upper() string

Upper converts the string to uppercase

func (*StringHelper) Words

func (s *StringHelper) Words(words int) string

Words returns the first n words

type Tappable

type Tappable[T any] interface {
	Tap(fn func(T)) T
}

Tappable is an interface that types can implement for tap-style chaining.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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