stringutils

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: MIT Imports: 4 Imported by: 2

README

stringutils Build Status Go Report Card Coverage Status

Package stringutils provides useful string operations.

Details

  • Contains: checks if slice contains a string.
  • ContainsAnySubstring: checks if string contains any of provided substring.
  • DeDup: removes duplicates from slice of strings, optimized for performance, good for short slices only.
  • DeDupBig: removes duplicates from slice. Should be used instead of DeDup for large slices.
  • SliceToString: converts slice of any to a slice of strings.
  • HasCommonElement: checks if any element of the second slice is in the first slice.

Install and update

go get -u github.com/go-pkgz/stringutils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(src string, inSlice []string) bool

Contains string in slice

func ContainsAnySubstring

func ContainsAnySubstring(s string, subStrings []string) bool

ContainsAnySubstring checks if string contains any of provided substring

func DeDup

func DeDup(keys []string) []string

DeDup remove duplicates from slice. optimized for performance, good for short slices only!

func DeDupBig

func DeDupBig(keys []string) (result []string)

DeDupBig remove duplicates from slice. Should be used instead of DeDup for large slices

func HasCommonElement

func HasCommonElement(a, b []string) bool

HasCommonElement checks if any element of the second slice is in the first slice

func HasPrefixSlice added in v1.1.0

func HasPrefixSlice(prefix string, slice []string) bool

HasPrefixSlice checks if any string in the slice starts with the given prefix

func HasSuffixSlice added in v1.1.0

func HasSuffixSlice(suffix string, slice []string) bool

HasSuffixSlice checks if any string in the slice ends with the given suffix

func SliceToString

func SliceToString(s []any) []string

SliceToString converts slice of any to slice of string

Types

This section is empty.

Jump to

Keyboard shortcuts

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