arrutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 6 Imported by: 47

Documentation

Overview

Package arrutil provides some util functions for array, slice

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidType = errors.New("the input param type is invalid")

Functions

func Contains added in v0.3.6

func Contains(arr, val interface{}) bool

Contains check array(strings, intXs, uintXs) should be contains the given value(int(X),string).

func GetRandomOne added in v0.3.8

func GetRandomOne(arr interface{}) interface{}

GetRandomOne get random element from an array/slice

func HasValue added in v0.3.13

func HasValue(arr, val interface{}) bool

HasValue check array(strings, intXs, uintXs) should be contains the given value(int(X),string).

func Int64sHas added in v0.3.6

func Int64sHas(ints []int64, val int64) bool

Int64sHas check the []int64 contains the given value

func IntsHas added in v0.3.6

func IntsHas(ints []int, val int) bool

IntsHas check the []int contains the given value

func MustToInt64s added in v0.3.13

func MustToInt64s(arr interface{}) []int64

MustToInt64s convert interface{}(allow: array,slice) to []int64

func MustToStrings added in v0.3.13

func MustToStrings(arr interface{}) []string

MustToStrings convert interface{}(allow: array,slice) to []string

func NotContains added in v0.3.6

func NotContains(arr, val interface{}) bool

NotContains check array(strings, ints, uints) should be not contains the given value.

func Reverse

func Reverse(ss []string)

Reverse string slice [site user info 0] -> [0 info user site]

func SliceToInt64s added in v0.3.13

func SliceToInt64s(arr []interface{}) []int64

SliceToInt64s convert []interface{} to []int64

func SliceToStrings added in v0.3.13

func SliceToStrings(arr []interface{}) []string

SliceToStrings convert []interface{} to []string

func StringsHas added in v0.3.6

func StringsHas(ss []string, val string) bool

StringsHas check the []string contains the given element

func StringsRemove added in v0.1.4

func StringsRemove(ss []string, s string) []string

StringsRemove an value form an string slice

func StringsToInts added in v0.2.2

func StringsToInts(ss []string) (ints []int, err error)

StringsToInts string slice to int slice

func ToInt64s added in v0.3.13

func ToInt64s(arr interface{}) (ret []int64, err error)

ToInt64s convert interface{}(allow: array,slice) to []int64

func ToStrings added in v0.3.13

func ToStrings(arr interface{}) (ret []string, err error)

ToStrings convert interface{}(allow: array,slice) to []string

func TrimStrings added in v0.2.2

func TrimStrings(ss []string, cutSet ...string) (ns []string)

TrimStrings trim string slice item.

Types

type Ints added in v0.3.9

type Ints []int

Ints type

func (Ints) Has added in v0.3.9

func (is Ints) Has(i int) bool

Has given element

func (Ints) String added in v0.3.9

func (is Ints) String() string

String to string

type Strings added in v0.3.9

type Strings []string

Strings type

func (Strings) Has added in v0.3.9

func (ss Strings) Has(sub string) bool

Has given element

func (Strings) String added in v0.3.9

func (ss Strings) String() string

String to string

Jump to

Keyboard shortcuts

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