golang用strings.Split切割字符串

kv := strings.Split(authString, " ")
	if len(kv) != 2 || kv[0] != "Bearer" {
		beego.Debug("AuthString invalid:"+authString)
		base.ReturnError(errors.New("AuthString invalid:"+authString))
		return ""
	}
	tokenString := kv[1]
kov := strings.Split(cond, ":")
		if len(kov) != 3 {
			return queryVal, queryOp, errors.New("Query format != k:o:v")
		}

  

prefixemail := strings.Split(email, "@")[0]

 s = strings.Split("abc,abc", "")
    fmt.Println(s, len(s))
    s = strings.Split("", ",")
    fmt.Println(s, len(s))
    s = strings.Split("abc,abc", ",")
    fmt.Println(s, len(s))
    s = strings.Split("abc,abc", "|")
    fmt.Println(s, len(s))
    fmt.Println(len(""))
    fmt.Println(len([]string{""}))
    str := ""
    fmt.Println(str[0])



运行结果:

[] 0    //返回空数组
[a b c , a b c] 7  //返回7个数组元素
[] 1  //返回一个包含空字符元素的数组, 数组长度是1
[abc abc] 2
[abc,abc] 1
0
1
panic: runtime error: index out of range