fmt.Println("go"=="go")
fmt.Println("GO"=="go")
fmt.Println(strings.Compare("GO","go"))
fmt.Println(strings.Compare("go","go"))
fmt.Println(strings.EqualFold("GO","go"))
输出结果
true
false
-1
0
true
- 内建方法"==”,区分大小写,最简单的方法
- Compare函数,区分大小写,比内建方法“==”的速度要快
/ Compare is included only for symmetry with package bytes.
// It is usually clearer and always faster to use the built-in
// string comparison operators ==, <, >, and so on.
func Compare(a, b string) int
- 比较UTF-8编码条件下是否相等,不区分大小写
// EqualFold reports whether s and t, interpreted as UTF-8 strings, // are equal under Unicode case-folding. func EqualFold(s, t string) bool