Documentation
¶
Index ¶
- Constants
- func Contains(s, substr string) bool
- func EndsWith(s, suffix string) bool
- func Equals(s, t string) bool
- func Format(pattern string, data map[string]any) string
- func HasPrefix(s, prefix string) bool
- func HasSuffix(s, suffix string) bool
- func IndexOf(s, substr string) int
- func Join(a []string, sep string) string
- func LowerCase(s string) string
- func MustToBool(s string) bool
- func MustToFloat(s string) float64
- func MustToFloat32(s string) float32
- func MustToFloat64(s string) float64
- func MustToInt(s string) int
- func MustToInt64(s string) int64
- func PadLeft(s string, n int, padding string) string
- func PadRight(s string, n int, padding string) string
- func PadZero(s string, n int) string
- func Random(n int, seeds ...string) string
- func Repeat(s string, n int) string
- func Replace(s, old, new string, n int) string
- func ReplaceAll(s, old, new string) string
- func ReplaceAllFunc(s string, re string, f func([]byte) []byte) string
- func Slice(s string, start int, end ...int) string
- func Split(s, sep string) []string
- func SplitN(s, sep string, n int) []string
- func StartsWith(s, prefix string) bool
- func Template(rawTemplate string, data map[string]any) (builtText string, err error)
- func ToBool(s string) (bool, error)
- func ToFloat(s string) (float64, error)
- func ToFloat32(s string) (float32, error)
- func ToFloat64(s string) (float64, error)
- func ToInt(s string) (int, error)
- func ToInt64(s string) (int64, error)
- func ToLower(s string) string
- func ToTitle(s string) string
- func ToUpper(s string) string
- func Trim(s, cutset string) string
- func TrimLeft(s, cutset string) string
- func TrimPrefix(s, prefix string) string
- func TrimRight(s, cutset string) string
- func TrimSpace(s string) string
- func TrimSuffix(s, suffix string) string
- func UpperCase(s string) string
- type Builder
- type Value
Constants ¶
const FormatRe = `\{\{([^\}]+)\}\}`
FormatRe is the regular expression for format.
Variables ¶
This section is empty.
Functions ¶
func IndexOf ¶
IndexOf returns the index of the first occurrence of substr in s, or -1 if substr is not found.
func Join ¶
Join joins the elements of a to create a single string. The separator string sep is placed between elements in the resulting string.
func MustToBool ¶
MustToBool converts a string to a boolean. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.
func MustToFloat32 ¶
MustToFloat32 converts a string to a float32.
func MustToFloat64 ¶
MustToFloat64 converts a string to a float64.
func Replace ¶
Replace returns a copy of s with the first n non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string. If n < 0, there is no limit on the number of replacements.
func ReplaceAll ¶
ReplaceAll returns a copy of s with all non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string.
func ReplaceAllFunc ¶
ReplaceAllFunc returns a copy of s with all non-overlapping instances of the function f applied to old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string.
func StartsWith ¶
StartsWith returns true if s starts with prefix.
func ToBool ¶
ToBool converts a string to a boolean. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.
func TrimPrefix ¶ added in v1.3.7
TrimPrefix returns s without the provided leading prefix string.
func TrimSuffix ¶ added in v1.3.7
TrimSuffix returns s without the provided trailing suffix string.
Types ¶
type Builder ¶ added in v1.4.11
func NewBuilder ¶ added in v1.4.11
func NewBuilder() Builder