stringslice

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: Apache-2.0 Imports: 2 Imported by: 2

Documentation

Overview

Package stringslice provides some utilities on top of []string for lazy developers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(slice []string, match MatchFunc) []string

Filter returns a slice containing the elements of slice for which match returns true.

func Map

func Map(slice []string, mapping ...MapFunc) []string

Map returns a slice containing the result of mapping for each element in the slice.

func MatchAll

func MatchAll(slice []string, match MatchFunc) bool

MatchAll returns true if match returns true for all elements of slice.

func MatchAny

func MatchAny(slice []string, match MatchFunc) bool

MatchAny returns true if match returns true for any element of slice.

Types

type MapFunc

type MapFunc func(string) string

MapFunc is a function that maps a string to a string.

func AddPrefix

func AddPrefix(prefix string) MapFunc

AddPrefix returns a map function that adds the given prefix to the element.

func AddSuffix

func AddSuffix(suffix string) MapFunc

AddSuffix returns a map function that adds the given suffix to the element.

func Repeat

func Repeat(count int) MapFunc

Repeat returns a map function that calls strings.Repeat With the element and the given argument.

func Replace

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

Replace returns a map function that calls strings.Replace With the element and the given argument.

func ReplaceAll

func ReplaceAll(old, new string) MapFunc

ReplaceAll returns a map function that calls strings.ReplaceAll With the element and the given argument.

func ToLowerSpecial

func ToLowerSpecial(c unicode.SpecialCase) MapFunc

ToLowerSpecial returns a map function that calls strings.ToLowerSpecial With the element and the given argument.

func ToTitleSpecial

func ToTitleSpecial(c unicode.SpecialCase) MapFunc

ToTitleSpecial returns a map function that calls strings.ToTitleSpecial With the element and the given argument.

func ToUpperSpecial

func ToUpperSpecial(c unicode.SpecialCase) MapFunc

ToUpperSpecial returns a map function that calls strings.ToUpperSpecial With the element and the given argument.

func Trim

func Trim(cutset string) MapFunc

Trim returns a map function that calls strings.Trim With the element and the given argument.

func TrimFunc

func TrimFunc(f func(rune) bool) MapFunc

TrimFunc returns a map function that calls strings.TrimFunc With the element and the given argument.

func TrimLeft

func TrimLeft(cutset string) MapFunc

TrimLeft returns a map function that calls strings.TrimLeft With the element and the given argument.

func TrimLeftFunc

func TrimLeftFunc(f func(rune) bool) MapFunc

TrimLeftFunc returns a map function that calls strings.TrimLeftFunc With the element and the given argument.

func TrimPrefix

func TrimPrefix(prefix string) MapFunc

TrimPrefix returns a map function that calls strings.TrimPrefix With the element and the given argument.

func TrimRight

func TrimRight(cutset string) MapFunc

TrimRight returns a map function that calls strings.TrimRight With the element and the given argument.

func TrimRightFunc

func TrimRightFunc(f func(rune) bool) MapFunc

TrimRightFunc returns a map function that calls strings.TrimRightFunc With the element and the given argument.

func TrimSuffix

func TrimSuffix(suffix string) MapFunc

TrimSuffix returns a map function that calls strings.TrimSuffix With the element and the given argument.

type MatchFunc

type MatchFunc func(string) bool

MatchFunc is a function that matches elements in a string slice.

func Contains

func Contains(substr string) MatchFunc

Contains returns a filter function that calls strings.Contains with the element and the given argument.

func ContainsAny

func ContainsAny(chars string) MatchFunc

ContainsAny returns a filter function that calls strings.ContainsAny with the element and the given argument.

func ContainsRune

func ContainsRune(r rune) MatchFunc

ContainsRune returns a filter function that calls strings.ContainsRune with the element and the given argument.

func Equal

func Equal(t string) MatchFunc

Equal returns a filter function that returns true if the element equals the given argument.

func EqualFold

func EqualFold(t string) MatchFunc

EqualFold returns a filter function that calls strings.EqualFold with the element and the given argument.

func HasPrefix

func HasPrefix(prefix string) MatchFunc

HasPrefix returns a filter function that calls strings.HasPrefix with the element and the given argument.

func HasSuffix

func HasSuffix(suffix string) MatchFunc

HasSuffix returns a filter function that calls strings.HasSuffix with the element and the given argument.

func Unique

func Unique(size int) MatchFunc

Unique returns a filter function that returns true for an element if it is the first time the function has been called with that element.

Jump to

Keyboard shortcuts

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