stringx

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(s, substr string) bool

Contains returns true if s contains substr.

func EndsWith

func EndsWith(s, suffix string) bool

EndsWith returns true if s ends with suffix.

func Equals

func Equals(s, t string) bool

Equals returns true if s1 and s2 are equal.

func HasPrefix

func HasPrefix(s, prefix string) bool

HasPrefix returns true if s starts with prefix.

func HasSuffix

func HasSuffix(s, suffix string) bool

HasSuffix returns true if s ends with suffix.

func IndexOf

func IndexOf(s, substr string) int

IndexOf returns the index of the first occurrence of substr in s, or -1 if substr is not found.

func Join

func Join(a []string, sep string) string

Join joins the elements of a to create a single string. The separator string sep is placed between elements in the resulting string.

func LowerCase

func LowerCase(s string) string

LowerCase returns a copy of s with all uppercase letters converted to lowercase.

func MustToBool

func MustToBool(s string) bool

MustToBool converts a string to a boolean. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.

func MustToFloat

func MustToFloat(s string) float64

MustToFloat converts a string to a float64.

func MustToFloat32

func MustToFloat32(s string) float32

MustToFloat32 converts a string to a float32.

func MustToFloat64

func MustToFloat64(s string) float64

MustToFloat64 converts a string to a float64.

func MustToInt

func MustToInt(s string) int

MustToInt converts a string to an integer.

func MustToInt64

func MustToInt64(s string) int64

MustToInt64 converts a string to an integer.

func PadLeft

func PadLeft(s string, n int, padding string) string

PadLeft ...

func PadRight

func PadRight(s string, n int, padding string) string

PadRight ...

func PadZero

func PadZero(s string, n int) string

PadZero ...

func Random

func Random(n int, seeds ...string) string

random returns a random string of length n.

func Repeat

func Repeat(s string, n int) string

Repeat returns a new string consisting of n copies of the string s.

func Replace

func Replace(s, old, new string, n int) string

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

func ReplaceAll(s, old, new string) string

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

func ReplaceAllFunc(s string, re string, f func([]byte) []byte) string

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 Slice

func Slice(s string, start int, end ...int) string

Slice returns a substring of s.

func Split

func Split(s, sep string) []string

Split splits a string into a slice of strings.

func SplitN

func SplitN(s, sep string, n int) []string

SplitN splits a string into a slice of strings.

func StartsWith

func StartsWith(s, prefix string) bool

StartsWith returns true if s starts with prefix.

func ToBool

func ToBool(s string) (bool, error)

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 ToFloat

func ToFloat(s string) (float64, error)

ToFloat converts a string to a float64.

func ToFloat32

func ToFloat32(s string) (float32, error)

ToFloat32 converts a string to a float32.

func ToFloat64

func ToFloat64(s string) (float64, error)

ToFloat64 converts a string to a float64.

func ToInt

func ToInt(s string) (int, error)

ToInt converts a string to an integer.

func ToInt64

func ToInt64(s string) (int64, error)

ToInt64 converts a string to an integer.

func ToLower

func ToLower(s string) string

ToLower returns a copy of s with all uppercase letters converted to lowercase.

func ToTitle

func ToTitle(s string) string

ToTitle returns a copy of the string s with all Unicode letters that begin

func ToUpper

func ToUpper(s string) string

ToUpper returns a copy of s with all lowercase letters converted to uppercase.

func Trim

func Trim(s, cutset string) string

Trim returns a substring of s without leading and trailing cutsets.

func TrimLeft

func TrimLeft(s, cutset string) string

TrimLeft returns a substring of s without leading cutsets.

func TrimRight

func TrimRight(s, cutset string) string

TrimRight returns a substring of s without trailing cutsets.

func TrimSpace

func TrimSpace(s string) string

TrimSpace returns a substring of s without leading and trailing spaces.

func UpperCase

func UpperCase(s string) string

UpperCase returns a copy of s with all lowercase letters converted to uppercase.

Types

This section is empty.

Jump to

Keyboard shortcuts

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