xstring

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidStartPosition is an error that indicates the start position is invalid.
	ErrInvalidStartPosition = fmt.Errorf("start position is invalid")
	// ErrInvalidStopPosition is an error that indicates the stop position is invalid.
	ErrInvalidStopPosition = fmt.Errorf("stop position is invalid")
)
View Source
var (
	IntSliceSymbol = ","
)

Functions

func Contains

func Contains(list []string, str string) bool

Contains checks if str is in list.

func Filter

func Filter(s string, filter func(r rune) bool) string

Filter filters chars from s with given filter function.

func FirstN

func FirstN(s string, n int, ellipsis ...string) string

FirstN returns first n runes from s.

func HasEmpty

func HasEmpty(args ...string) bool

HasEmpty checks if there are empty strings in args.

func IntSliceToString

func IntSliceToString(slices []int) string

IntSliceToString []int{1,2,3}=>1,2,3

func IntStringToSlice

func IntStringToSlice(si string) []int

IntStringToSlice 字符转int切片 1,2,3=>[]int{1,2,3}

func Join

func Join(sep byte, elem ...string) string

Join joins any number of elements into a single string, separating them with given sep. Empty elements are ignored. However, if the argument list is empty or all its elements are empty, Join returns an empty string.

func NotEmpty

func NotEmpty(args ...string) bool

NotEmpty checks if all strings are not empty in args.

func Rand

func Rand() string

Rand returns a random string.

func RandId

func RandId() string

RandId returns a random id string.

func RandomN

func RandomN(n int) string

RandomN returns a random string with length n.

func RandomNumberN

func RandomNumberN(length int) string

func Remove

func Remove(strings []string, strs ...string) []string

Remove removes given strs from strings.

func Reverse

func Reverse(s string) string

Reverse reverses s.

func Seed

func Seed(seed int64)

Seed sets the seed to seed.

func Substr

func Substr(str string, start, stop int) (string, error)

Substr returns runes between start and stop [start, stop) regardless of the chars are ascii or utf8.

func TakeOne

func TakeOne(valid, or string) string

TakeOne returns valid string if not empty or later one.

func TakeWithPriority

func TakeWithPriority(fns ...func() string) string

TakeWithPriority returns the first not empty result from fns.

func ToCamelCase

func ToCamelCase(s string) string

ToCamelCase returns the string that converts the first letter to lowercase.

Types

This section is empty.

Jump to

Keyboard shortcuts

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