strs

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(vs []string, f func(string) bool) bool

All returns `true` if all of the strings in the slice satisfy the predicate `f`.

func Any

func Any(vs []string, f func(string) bool) bool

Any returns `true` if one of the strings in the slice satisfies the predicate `f`.

func AppendUnique

func AppendUnique(slice []string, elems ...string) (sl []string, appended int)

AppendUnique appends the string to the array if its not existing. The bool indicates if an append occurred.

func Filter

func Filter(vs []string, f func(string) bool) []string

Filter returns a new slice containing all strings in the slice that satisfy the predicate `f`.

func Fmt

func Fmt(format string, a ...interface{}) string

Fmt returns a formatted string.

func FmtW

func FmtW(w io.Writer, format string, a ...interface{}) (int, error)

FmtW returns a formatted string.

func Includes

func Includes(vs []string, t string) bool

Includes returns `true` if the string t is in the slice.

func Index

func Index(vs []string, t string) int

Index returns the first index of the target string `t`, or -1 if no match is found.

func IsEmpty

func IsEmpty(s string) bool

IsEmpty returns `true` if the string is not empty.

func IsNotEmpty

func IsNotEmpty(s string) bool

IsNotEmpty returns `true` if the string is not empty.

func MakeUnique

func MakeUnique(slice []string) []string

MakeUnique makes the slice containing only unique items. This function does pertain the order!

func Map

func Map(vs []string, f func(string) string) []string

Map returns a new slice containing the results of applying the function `f` to each string in the original slice.

func RandomString

func RandomString(length int) string

RandomString generates a random string of length `length`.

func RandomStringCharSet

func RandomStringCharSet(length int, charset string) string

RandomStringCharSet generates a random string of length `length` with the charset `charset`.

func Remove

func Remove(slice []string, s string) (newitems []string, removed int)

Remove removes all occurrences from the slice. The int indicates if a remove occurred.

func SplitLines

func SplitLines(s string) []string

SplitLines splits a string into an array of strings.

func SplitLinesN

func SplitLinesN(s string, n int) []string

SplitLinesN splits a string into an array of `n` strings + a remainder.

Types

type Pair

type Pair struct {
	First  string
	Second string
}

Pair hold two pairs of strings.

type StringSet

type StringSet map[string]bool

StringSet mimics a simple string set type.

func (StringSet) Exists

func (m StringSet) Exists(s string) bool

Exists checks existence of `s` in the set.

func (StringSet) Insert

func (m StringSet) Insert(s string)

Insert adds `s` to the set.

func (StringSet) Remove

func (m StringSet) Remove(s string)

Remove removes `s` from the set.

func (*StringSet) ToList

func (m *StringSet) ToList() (keys []string)

ToList gets the keys of a string set.

Jump to

Keyboard shortcuts

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