In Go language, strings are different from other languages like Java, C++, Python, etc. It is a sequence of variable-width characters where each and every character is represented by one or more bytes using UTF-8 Encoding.
In Go strings, you are allowed to compare two strings with each other without any error even if they are written in different cases(lowercase and uppercase) with the help of EqualFold() function. Or in other, this function is used to check whether the specified strings are interpreted as UTF-8 strings and are equal under Unicode case-folding. This function returns true if the given strings are equal under Unicode case-folding or return false if the given strings are not equal under Unicode case-folding. It is defined under the strings package so, you have to import strings package in your program for accessing EqualFold function.
func EqualFold(str1, str2 string) bool
The return type of this function is of the bool type. Let us discuss this concept with the help of the examples:
Result 1: true Result 2: true Result 3: false Result 4: true Result 5: true Result 6: true
- Checking Slice of bytes for equality under Unicode case folding in Golang
- Check If the Rune is a Unicode Punctuation Character or not in Golang
- How to check equality of slices of bytes in Golang?
- How to convert a string in lower case in Golang?
- Structure Equality in Golang
- How to check the specified rune in Golang String?
- Check if the String starts with specified prefix in Golang
- Check if the given characters is present in Golang String
- Check if the String ends with specified suffix in Golang
- How to Map a Rune to the Specified Case in Golang?
- How to Map a Rune to Title Case in Golang?
- Golang | Deadlock and Default Case in Select Statement
- How to convert a slice of bytes in title case in Golang?
- Check if the given slice is sorted in Golang
- Check If the Rune is a Letter or not in Golang
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.