IsUpper

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