Indexing a string indexes its bytes, not its runes (a rune is the unicode code number).
What you want to do is check the first character ( rune ) string , and not its first byte in UTF-8 encoded form. And for this there is support in the standard library: unicode.IsUpper() .
To get the first rune , you can convert string to a piece of runes and transfer the first element (with index 0).
ins := []string{ "å/Å/ä/Ä/ö/Ö", "Å/ä/Ä/ö/Ö"} for _, s := range ins { fmt.Println(s, unicode.IsUpper([]rune(s)[0])) }
Conclusion:
å/Å/ä/Ä/ö/Ö false Å/ä/Ä/ö/Ö true
source share