aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/go-faker/faker/v4/pkg/slice/helpers.go
blob: c85c74b319ac7bd91c98929dc966e88417db9ca8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package slice

import (
	"strconv"
)

// Contains Check item in slice string type
func Contains(slice []string, item string) bool {
	for _, s := range slice {
		if s == item {
			return true
		}
	}
	return false
}

// ContainsRune Check item in map rune type
func ContainsRune(set map[rune]struct{}, item rune) bool {
	_, ok := set[item]
	return ok
}

// ContainsValue check if value exists in slice, no matter its type
func ContainsValue(slice []interface{}, value interface{}) bool {
	for _, v := range slice {
		if v == value {
			return true
		}
	}
	return false
}

// IntToString Convert slice int to slice string
func IntToString(intSl []int) (str []string) {
	for i := range intSl {
		number := intSl[i]
		text := strconv.Itoa(number)
		str = append(str, text)
	}
	return str
}