xstrings

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join[T ~string](elems []T, sep string) string

Join concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string.

This is a copy of Go's strings.Join but uses generic type for the elements.

func Pointer deprecated

func Pointer[T ~string](s T) *T

Pointer returns string typed s as pointer.

Deprecated: use xptr.To().

func RepeatJoin

func RepeatJoin[T ~string](s T, count int, sep string) string

RepeatJoin returns a string consisting of count copies of the string s concatenated using the separate string sep. This is similar as using RepeatSlice together with Go's strings.Join. Panics when count is negative.

func RepeatSlice

func RepeatSlice[T ~string](s T, count int) []string

RepeatSlice returns a []string consisting of count copies of the string s. When count is zero, empty slice is returned. Panics when count is out of range when making slice.

func ScanTokens added in v1.9.0

func ScanTokens(s string) []string

ScanTokens scans a string and returns a slice of tokens.

Tokens are separated by whitespace, unless they are within quotes. If a token is within quotes, the whitespace is preserved within the token. Any character that is not whitespace or a quote is part of a token.

func Search[T ~string](a []T, x T) int

Search returns the position of x in slice a or -1 when x is not part of a.

func SliceHas

func SliceHas[T ~string](a []T, x T) bool

SliceHas returns true when x is found in slice a.

Types

This section is empty.

Jump to

Keyboard shortcuts

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