Checks if a string is upper case.

Use strings.ToUpper() to convert the string to upper case and compare it to the original string.

代码实现

import "strings"

func IsUpper(s string) bool {
    return strings.ToUpper(s) == s
}

使用样例

IsUpper("GO") // true
IsUpper("Go") // false