Documentation
¶
Overview ¶
Package support provides helper utilities for the framework.
Index ¶
- Variables
- func Now() time.Time
- func RandomBytes(n int) ([]byte, error)
- func RandomString(n int) string
- func Retry(attempts int, sleep time.Duration, fn func() error) error
- func Sleep(d time.Duration)
- func Tap[T any](value T, fn func(T)) T
- func ToPascalCase(s string) string
- func ToSnakeCase(s string) string
- func Unless[T any](condition bool, value T, fn func(T) T) T
- func When[T any](condition bool, value T, fn func(T) T) T
- func With[T any, R any](value T, fn func(T) R) R
- type ArrayHelper
- type PathHelper
- func (p *PathHelper) Base(path string) string
- func (p *PathHelper) Dir(path string) string
- func (p *PathHelper) Exists(path string) bool
- func (p *PathHelper) Ext(path string) string
- func (p *PathHelper) IsDir(path string) bool
- func (p *PathHelper) IsFile(path string) bool
- func (p *PathHelper) Join(elem ...string) string
- type StringHelper
- func (s *StringHelper) Camel(str string) string
- func (s *StringHelper) Contains(str, substr string) bool
- func (s *StringHelper) EndsWith(str, suffix string) bool
- func (s *StringHelper) Kebab(str string) string
- func (s *StringHelper) Limit(str string, limit int, end ...string) string
- func (s *StringHelper) Lower(str string) string
- func (s *StringHelper) Pascal(str string) string
- func (s *StringHelper) Random(length int) string
- func (s *StringHelper) Replace(str, old, new string) string
- func (s *StringHelper) Slug(str string) string
- func (s *StringHelper) Snake(str string) string
- func (s *StringHelper) StartsWith(str, prefix string) bool
- func (s *StringHelper) Title(str string) string
- func (s *StringHelper) Trim(str string) string
- func (s *StringHelper) UUID() string
- func (s *StringHelper) Upper(str string) string
Constants ¶
This section is empty.
Variables ¶
var Arr = &ArrayHelper{}
Arr provides array/slice helper functions.
var Path = &PathHelper{}
Path provides path helper functions.
var Str = &StringHelper{}
Str provides string helper functions.
Functions ¶
func Tap ¶
func Tap[T any](value T, fn func(T)) T
Tap calls the given function and returns the value.
func ToPascalCase ¶
ToPascalCase converts a string to PascalCase.
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) Upper ¶
func (s *StringHelper) Upper(str string) string
Upper converts a string to uppercase.