package arrayex import ( "regexp" "strings" ) func IndexOf(a []string, e interface{}) int { n := len(a) var i int = 0 for ; i < n; i++ { if cmp(e, a[i]) == 0 { return i } } return -1 } func cmp(a interface{}, b interface{}) int { s1 := a.(string) s2 := b.(string) if strings.Index(s2, "*") > -1 { h, _ := regexp.MatchString(strings.Replace(s2, "*", ".*", 1), s1) if h { return 0 } } return strings.Compare(s1, s2) }