sliceutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](inputSlice []T, element T) bool

Contains if a slice contains an element

func ContainsItems

func ContainsItems[T comparable](s1 []T, s2 []T) bool

ContainsItems checks if s1 contains s2

func Dedupe

func Dedupe[T comparable](inputSlice []T) (result []T)

Dedupe removes duplicates from a slice of elements preserving the order

func PickRandom

func PickRandom[T any](v []T) T

PickRandom item from a slice of elements

func PruneEmptyStrings

func PruneEmptyStrings(v []string) []string

PruneEmptyStrings from the slice

func PruneEqual

func PruneEqual[T comparable](inputSlice []T, equalTo T) (r []T)

PruneEqual removes items from the slice equal to the specified value

func RandSlice

func RandSlice(slice interface{})

切片乱序

func RandomInterface

func RandomInterface(obj []interface{}) []interface{}

interface

func RandomString

func RandomString(strings []string) string

字符串数组

func ToInt

func ToInt(s []string) ([]int, error)

ToInt converts a slice of strings to a slice of ints

Types

This section is empty.

Jump to

Keyboard shortcuts

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