在Go中,可以使用“==”操作符来判断两个字符串是否相等。例如:

str1 := "hello"
str2 := "world"
if str1 == str2 {
    fmt.Println("Strings are equal")
} else {
    fmt.Println("Strings are not equal")
}

此代码将打印“Strings are not equal”,因为str1和str2不相等。

go判断字符串相等

原文地址: http://www.cveoy.top/t/topic/GBU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录