support

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package support provides helper utilities for the framework.

Index

Constants

This section is empty.

Variables

View Source
var Arr = &ArrayHelper{}

Arr provides array/slice helper functions.

View Source
var Path = &PathHelper{}

Path provides path helper functions.

View Source
var Str = &StringHelper{}

Str provides string helper functions.

Functions

func Now

func Now() time.Time

Now returns the current time.

func RandomBytes

func RandomBytes(n int) ([]byte, error)

RandomBytes generates random bytes.

func RandomString

func RandomString(n int) string

RandomString generates a random string.

func Retry

func Retry(attempts int, sleep time.Duration, fn func() error) error

Retry retries a function until it succeeds or max attempts is reached.

func Sleep

func Sleep(d time.Duration)

Sleep pauses for the given duration.

func Tap

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

Tap calls the given function and returns the value.

func ToPascalCase

func ToPascalCase(s string) string

ToPascalCase converts a string to PascalCase.

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase converts a string to snake_case.

func Unless

func Unless[T any](condition bool, value T, fn func(T) T) T

Unless conditionally executes a function when condition is false.

func When

func When[T any](condition bool, value T, fn func(T) T) T

When conditionally executes a function.

func With

func With[T any, R any](value T, fn func(T) R) R

With calls the given function with the value and returns the result.

Types

type ArrayHelper

type ArrayHelper struct{}

ArrayHelper contains array manipulation methods.

func (*ArrayHelper) Contains

func (a *ArrayHelper) Contains(slice any, item any) bool

Contains checks if an array contains a value.

func (*ArrayHelper) First

func (a *ArrayHelper) First(slice any) any

First returns the first element of a slice.

func (*ArrayHelper) Last

func (a *ArrayHelper) Last(slice any) any

Last returns the last element of a slice.

type PathHelper

type PathHelper struct{}

PathHelper contains path manipulation methods.

func (*PathHelper) Base

func (p *PathHelper) Base(path string) string

Base returns the base name of a path.

func (*PathHelper) Dir

func (p *PathHelper) Dir(path string) string

Dir returns the directory of a path.

func (*PathHelper) Exists

func (p *PathHelper) Exists(path string) bool

Exists checks if a path exists.

func (*PathHelper) Ext

func (p *PathHelper) Ext(path string) string

Ext returns the file extension.

func (*PathHelper) IsDir

func (p *PathHelper) IsDir(path string) bool

IsDir checks if a path is a directory.

func (*PathHelper) IsFile

func (p *PathHelper) IsFile(path string) bool

IsFile checks if a path is a file.

func (*PathHelper) Join

func (p *PathHelper) Join(elem ...string) string

Join joins path elements.

type StringHelper

type StringHelper struct{}

StringHelper contains string manipulation methods.

func (*StringHelper) Camel

func (s *StringHelper) Camel(str string) string

Camel converts a string to camelCase.

func (*StringHelper) Contains

func (s *StringHelper) Contains(str, substr string) bool

Contains checks if a string contains a substring.

func (*StringHelper) EndsWith

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

EndsWith checks if a string ends with a suffix.

func (*StringHelper) Kebab

func (s *StringHelper) Kebab(str string) string

Kebab converts a string to kebab-case.

func (*StringHelper) Limit

func (s *StringHelper) Limit(str string, limit int, end ...string) string

Limit limits a string to the given length.

func (*StringHelper) Lower

func (s *StringHelper) Lower(str string) string

Lower converts a string to lowercase.

func (*StringHelper) Pascal

func (s *StringHelper) Pascal(str string) string

Pascal converts a string to PascalCase.

func (*StringHelper) Random

func (s *StringHelper) Random(length int) string

Random generates a random string of the given length.

func (*StringHelper) Replace

func (s *StringHelper) Replace(str, old, new string) string

Replace replaces occurrences in a string.

func (*StringHelper) Slug

func (s *StringHelper) Slug(str string) string

Slug generates a URL-friendly slug from a string.

func (*StringHelper) Snake

func (s *StringHelper) Snake(str string) string

Snake converts a string to snake_case.

func (*StringHelper) StartsWith

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

StartsWith checks if a string starts with a prefix.

func (*StringHelper) Title

func (s *StringHelper) Title(str string) string

Title converts a string to Title Case.

func (*StringHelper) Trim

func (s *StringHelper) Trim(str string) string

Trim trims whitespace from a string.

func (*StringHelper) UUID

func (s *StringHelper) UUID() string

UUID generates a UUID v4 string.

func (*StringHelper) Upper

func (s *StringHelper) Upper(str string) string

Upper converts a string to uppercase.

Jump to

Keyboard shortcuts

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