Documentation
¶
Index ¶
- Variables
- func Random(length int) string
- func Substr(str string, start int, length ...int) string
- type FileOption
- type Str
- func (s *Str) After(search string) *Str
- func (s *Str) AfterLast(search string) *Str
- func (s *Str) Append(values ...string) *Str
- func (s *Str) Basename(suffix ...string) *Str
- func (s *Str) Before(search string) *Str
- func (s *Str) BeforeLast(search string) *Str
- func (s *Str) Between(start, end string) *Str
- func (s *Str) BetweenFirst(start, end string) *Str
- func (s *Str) Camel() *Str
- func (s *Str) CharAt(index int) string
- func (s *Str) ChopEnd(needle string, more ...string) *Str
- func (s *Str) ChopStart(needle string, more ...string) *Str
- func (s *Str) Contains(values ...string) bool
- func (s *Str) ContainsAll(values ...string) bool
- func (s *Str) Dirname(levels ...int) *Str
- func (s *Str) EndsWith(values ...string) bool
- func (s *Str) Exactly(value string) bool
- func (s *Str) Excerpt(phrase string, options ...excerptOption) *Str
- func (s *Str) Explode(delimiter string, limit ...int) []string
- func (s *Str) Finish(value string) *Str
- func (s *Str) Headline() *Str
- func (s *Str) Is(patterns ...string) bool
- func (s *Str) IsAscii() bool
- func (s *Str) IsEmpty() bool
- func (s *Str) IsMap() bool
- func (s *Str) IsMatch(patterns ...string) bool
- func (s *Str) IsNotEmpty() bool
- func (s *Str) IsSlice() bool
- func (s *Str) IsUlid() bool
- func (s *Str) IsUuid() bool
- func (s *Str) Kebab() *Str
- func (s *Str) LTrim(characters ...string) *Str
- func (s *Str) LcFirst() *Str
- func (s *Str) Length() int
- func (s *Str) Limit(limit int, end ...string) *Str
- func (s *Str) Lower() *Str
- func (s *Str) Mask(character string, index int, length ...int) *Str
- func (s *Str) Match(pattern string) *Str
- func (s *Str) MatchAll(pattern string) []string
- func (s *Str) NewLine(count ...int) *Str
- func (s *Str) PadBoth(length int, pad ...string) *Str
- func (s *Str) PadLeft(length int, pad ...string) *Str
- func (s *Str) PadRight(length int, pad ...string) *Str
- func (s *Str) Pipe(callback func(s string) string) *Str
- func (s *Str) Prepend(values ...string) *Str
- func (s *Str) RTrim(characters ...string) *Str
- func (s *Str) Remove(values ...string) *Str
- func (s *Str) Repeat(times int) *Str
- func (s *Str) Replace(search string, replace string, caseSensitive ...bool) *Str
- func (s *Str) ReplaceEnd(search string, replace string) *Str
- func (s *Str) ReplaceFirst(search string, replace string) *Str
- func (s *Str) ReplaceLast(search string, replace string) *Str
- func (s *Str) ReplaceMatches(pattern string, replace string) *Str
- func (s *Str) ReplaceStart(search string, replace string) *Str
- func (s *Str) Snake(delimiter ...string) *Str
- func (s *Str) Split(pattern string, limit ...int) []string
- func (s *Str) Squish() *Str
- func (s *Str) Start(prefix string) *Str
- func (s *Str) StartsWith(values ...string) bool
- func (s *Str) String() string
- func (s *Str) Studly() *Str
- func (s *Str) Substr(start int, length ...int) *Str
- func (s *Str) Swap(replacements map[string]string) *Str
- func (s *Str) Tap(callback func(Str)) *Str
- func (s *Str) Test(pattern string) bool
- func (s *Str) Title() *Str
- func (s *Str) Trim(characters ...string) *Str
- func (s *Str) UcFirst() *Str
- func (s *Str) UcSplit() []string
- func (s *Str) Unless(callback func(*Str) bool, fallback func(*Str) *Str) *Str
- func (s *Str) Upper() *Str
- func (s *Str) When(condition bool, callback ...func(*Str) *Str) *Str
- func (s *Str) WhenContains(value string, callback ...func(*Str) *Str) *Str
- func (s *Str) WhenContainsAll(values []string, callback ...func(*Str) *Str) *Str
- func (s *Str) WhenEmpty(callback ...func(*Str) *Str) *Str
- func (s *Str) WhenEndsWith(value []string, callback ...func(*Str) *Str) *Str
- func (s *Str) WhenExactly(value string, callback ...func(*Str) *Str) *Str
- func (s *Str) WhenIs(value string, callback ...func(*Str) *Str) *Str
- func (s *Str) WhenIsAscii(callback ...func(*Str) *Str) *Str
- func (s *Str) WhenIsUlid(callback ...func(*Str) *Str) *Str
- func (s *Str) WhenIsUuid(callback ...func(*Str) *Str) *Str
- func (s *Str) WhenNotEmpty(callback ...func(*Str) *Str) *Str
- func (s *Str) WhenNotExactly(value string, callback ...func(*Str) *Str) *Str
- func (s *Str) WhenStartsWith(value []string, callback ...func(*Str) *Str) *Str
- func (s *Str) WhenTest(pattern string, callback ...func(*Str) *Str) *Str
- func (s *Str) WordCount() int
- func (s *Str) Words(limit int, end ...string) *Str
Constants ¶
This section is empty.
Variables ¶
var FileUtil = fileUtil{}
var StringUtil = stringUtil{}
var ToolsUtil = toolsUtil{}
Functions ¶
Types ¶
type FileOption ¶
type FileOption func(*fileOption)
func WithMode ¶
func WithMode(mode os.FileMode) FileOption
WithMode sets the file mode for FilePutContents
type Str ¶
type Str struct {
// contains filtered or unexported fields
}
func (*Str) After ¶
After returns a new String instance with the substring after the first occurrence of the specified search string.
func (*Str) AfterLast ¶
AfterLast returns the String instance with the substring after the last occurrence of the specified search string.
func (*Str) Basename ¶
Basename returns the String instance with the basename of the current file path string, and trims the suffix based on the parameter(optional).
func (*Str) Before ¶
Before returns the String instance with the substring before the first occurrence of the specified search string.
func (*Str) BeforeLast ¶
BeforeLast returns the String instance with the substring before the last occurrence of the specified search string.
func (*Str) Between ¶
Between returns the String instance with the substring between the given start and end strings.
func (*Str) BetweenFirst ¶
BetweenFirst returns the String instance with the substring between the first occurrence of the given start string and the given end string.
func (*Str) ChopStart ¶
ChopStart remove the given string(s) if it exists at the start of the haystack.
func (*Str) Contains ¶
Contains returns true if the string contains the given value or any of the values.
func (*Str) ContainsAll ¶
ContainsAll returns true if the string contains all of the given values.
func (*Str) Dirname ¶
Dirname returns the String instance with the directory name of the current file path string.
func (*Str) EndsWith ¶
EndsWith returns true if the string ends with the given value or any of the values.
func (*Str) Finish ¶
Finish returns the String instance with the given value appended. If the given value already ends with the suffix, it will not be added twice.
func (*Str) IsNotEmpty ¶
IsNotEmpty returns true if the string is not empty.
func (*Str) LTrim ¶
LTrim returns the String instance with the leftmost occurrence of the given value removed.
func (*Str) Mask ¶
Mask returns the String instance with the given character masking the specified number of characters.
func (*Str) Match ¶
Match returns the String instance with the first occurrence of the given pattern.
func (*Str) PadBoth ¶
PadBoth returns the String instance padded to the left and right sides of the given length.
func (*Str) PadLeft ¶
PadLeft returns the String instance padded to the left side of the given length.
func (*Str) PadRight ¶
PadRight returns the String instance padded to the right side of the given length.
func (*Str) RTrim ¶
RTrim returns the String instance with the right occurrences of the given value removed.
func (*Str) Remove ¶
Remove returns the String instance with the first occurrence of the given value removed.
func (*Str) Replace ¶
Replace returns the String instance with all occurrences of the search string replaced by the given replacement string.
func (*Str) ReplaceEnd ¶
ReplaceEnd returns the String instance with the last occurrence of the given value replaced.
func (*Str) ReplaceFirst ¶
ReplaceFirst returns the String instance with the first occurrence of the given value replaced.
func (*Str) ReplaceLast ¶
ReplaceLast returns the String instance with the last occurrence of the given value replaced.
func (*Str) ReplaceMatches ¶
ReplaceMatches returns the String instance with all occurrences of the given pattern replaced by the given replacement string.
func (*Str) ReplaceStart ¶
ReplaceStart returns the String instance with the first occurrence of the given value replaced.
func (*Str) Squish ¶
Squish returns the String instance with consecutive whitespace characters collapsed into a single space.
func (*Str) StartsWith ¶
StartsWith returns true if the string starts with the given value or any of the values.
func (*Str) Substr ¶
Substr returns the String instance starting at the given index with the specified length.
func (*Str) Swap ¶
Swap replaces all occurrences of the search string with the given replacement string.
func (*Str) Trim ¶
Trim returns the String instance with trimmed characters from the left and right sides.
func (*Str) UcSplit ¶
UcSplit splits the string into words using uppercase characters as the delimiter.
func (*Str) Unless ¶
Unless returns the String instance with the given fallback applied if the given condition is false.
func (*Str) When ¶
When returns the String instance with the given callback applied if the given condition is true. If the condition is false, the fallback callback is applied (if provided).
func (*Str) WhenContains ¶
WhenContains returns the String instance with the given callback applied if the string contains the given value.
func (*Str) WhenContainsAll ¶
WhenContainsAll returns the String instance with the given callback applied if the string contains all the given values.
func (*Str) WhenEmpty ¶
WhenEmpty returns the String instance with the given callback applied if the string is empty.
func (*Str) WhenEndsWith ¶
WhenEndsWith returns the String instance with the given callback applied if the string ends with the given value.
func (*Str) WhenExactly ¶
WhenExactly returns the String instance with the given callback applied if the string is exactly the given value.
func (*Str) WhenIs ¶
WhenIs returns the String instance with the given callback applied if the string matches any of the given patterns.
func (*Str) WhenIsAscii ¶
WhenIsAscii returns the String instance with the given callback applied if the string contains only ASCII characters.
func (*Str) WhenIsUlid ¶
WhenIsUlid returns the String instance with the given callback applied if the string is a valid ULID.
func (*Str) WhenIsUuid ¶
WhenIsUuid returns the String instance with the given callback applied if the string is a valid UUID.
func (*Str) WhenNotEmpty ¶
WhenNotEmpty returns the String instance with the given callback applied if the string is not empty.
func (*Str) WhenNotExactly ¶
WhenNotExactly returns the String instance with the given callback applied if the string is not exactly the given value.
func (*Str) WhenStartsWith ¶
WhenStartsWith returns the String instance with the given callback applied if the string starts with the given value.
func (*Str) WhenTest ¶
WhenTest returns the String instance with the given callback applied if the string matches the given pattern.