slice

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 1 Imported by: 6

Documentation

Overview

Package slice provides a set of functions around slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsAll

func ContainsAll(slice, containedSlice []string) bool

ContainsAll return true if a string slice contains all elements of another string slice, otherwise returns false.

func HasString

func HasString(slice []string, s string) bool

HasString returns true if the given string value is found in the provided slice, otherwise returns false.

func IsEmpty

func IsEmpty(slice []string) bool

IsEmpty returns true if a string slice is empty or contains empty string values, otherwise returns false.

Types

type StringSlice

type StringSlice []string

StringSlice wraps a string slice to provide methods on top of it

func (StringSlice) Contains added in v1.2.0

func (ss StringSlice) Contains(s string) bool

Contains returns true if the given string value is found in the provided slice, otherwise returns false.

func (StringSlice) IsEmpty added in v1.2.0

func (ss StringSlice) IsEmpty() bool

IsEmpty returns true if a string slice is empty or contains empty string values, otherwise returns false.

func (StringSlice) ToCommaSeparatedString added in v1.2.0

func (ss StringSlice) ToCommaSeparatedString() string

ToCommaSeparatedString returns the elements of the string slice as a single string where all values are separated by the comma.

func (StringSlice) ToMap

func (ss StringSlice) ToMap(sep string) map[string]string

ToMap iterates over the slice and slices each element into substrings separated by sep. Then it adds a map key value pair where the key is the first substring and value is the second substring

If the sep is not found in the slice element then it's ignored

It returns the produced map after iterating all slice elements

Jump to

Keyboard shortcuts

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