package util import ( "math/rand" "regexp" "strings" ) func FindInSlice(slice []string, val string) bool { for _, item := range slice { if item == val { return true } } return false } func ValuesString(m map[string]string) string { values := make([]string, 0, len(m)) for _, v := range m { values = append(values, v) } return strings.Join(values, ", ") } var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)") var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])") func ToSnakeCase(str string) string { snake := matchFirstCap.ReplaceAllString(str, "${1}_${2}") snake = matchAllCap.ReplaceAllString(snake, "${1}_${2}") return strings.ToLower(snake) } const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" const ( letterIdxBits = 6 // 6 bits to represent a letter index letterIdxMask = 1<