Go中不区分大小写的字符串比较

问题描述:

How do I compare strings in a case insensitive manner?

For example, "Go" and "go" should be considered equal.

如何以不区分大小写的方式比较字符串? p>

例如 ,“开始”和“开始”应视为相等。 p> div>

https://golang.org/pkg/strings/#EqualFold is the function you are looking for. It is used like this (example from the linked documentation):

package main

import (
    "fmt"
    "strings"
)

func main() {
    fmt.Println(strings.EqualFold("Go", "go"))
}