stringutils

package
v0.0.0-...-5a7b0e6 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("Not found")

Functions

func ConcatSlice

func ConcatSlice(first, second []string) []string

func FormatFilters

func FormatFilters(filters []string) (map[string][]string, error)

FormatFilters Will receive an array of filters and will format them into a map of strings

Example:

[
 "environment:adios",
 "environment:hola",
 "cookbook:awesome",
 "roles:lalala",
]

The returned filters would look like:

map[string][]string [

"environment": ["adios","hola"],
"cookbook": ["awesome"],
"roles": ["lalala"],

]

func FormatFiltersWithKeyConverter

func FormatFiltersWithKeyConverter(filters []string,
	keyNameConverter func(string) string) (map[string][]string, error)

FormatFiltersWithKeyConverter The same as FormatFilters with the function keyNameConverter that converts the keys from aliases.

func GetFileName

func GetFileName(path string) string

func GetFullPlatformName

func GetFullPlatformName(name, release string) string

func GetFullProfileName

func GetFullProfileName(name, release string) string

func GetLastLine

func GetLastLine(input string) string

func IndexOf

func IndexOf(haystack []string, needle string) (int, error)

func IsNumeric

func IsNumeric(word string) bool

func SliceContains

func SliceContains(haystack []string, needle string) bool

func SliceDifference

func SliceDifference(first, second []string) []string

This method is used to return uncomman elements between the two slices. It returns (A-B) operation

func SliceFilter

func SliceFilter(in []string, f func(string) bool) []string

SliceFilter calls the input function on each element of the input slice and returns a slice of all elements for which the function returns true. From here: https://gobyexample.com/collection-functions

func SliceIntersection

func SliceIntersection(first, second []string) []string

This method is used to return comman elements between the two slices

func SliceReject

func SliceReject(haystack []string, needle string) []string

SliceReject takes a slice of strings and a string to removed a returns a slice with any matching reject strings removed.

func SubSlice

func SubSlice(s1 []string, s2 []string) bool

func Title

func Title(s string) string

Title returns a copy of the string s with all Unicode letters that begin words mapped to their title case. strings.Title has been deprecated since Go 1.18

func TitleReplace

func TitleReplace(s string, sep string, rep string) string

func TitleSplit

func TitleSplit(s string, sep string) string

TitleSplit splits the string s by sep and returns a copy of the string s with all Unicode letters that begin words mapped to their title case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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