init repo
This commit is contained in:
21
pkg/utils/arr.go
Normal file
21
pkg/utils/arr.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package utils
|
||||
|
||||
import "math/rand"
|
||||
|
||||
func InArray[T comparable](needle T, haystack []T) bool {
|
||||
for _, item := range haystack {
|
||||
if item == needle {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func NewRandNumber(length int) (string, error) {
|
||||
letters := []byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
|
||||
b := make([]byte, length)
|
||||
for i := range b {
|
||||
b[i] = letters[rand.Intn(len(letters))]
|
||||
}
|
||||
return string(b), nil
|
||||
}
|
||||
Reference in New Issue
Block a user