Checking Slice of bytes for equality under Unicode case folding in Golang
In Go language slice is more powerful, flexible, convenient than an array, and is a lightweight data structure. The slice is a variable-length sequence which stores elements of a similar type, you are not allowed to store different type of elements in the same slice.
In the Go slice of bytes, you are allowed to compare two slices with each other without any error even if the elements of these slices 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 slices are interpreted as UTF-8 strings and are equal under Unicode case-folding. This function returns true if the given slices are equal under Unicode case-folding or return false if the given slices are not equal under Unicode case-folding. It is defined under the bytes package so, you have to import bytes package in your program for accessing EqualFold function.
func EqualFold(slice_1, slice1_2 byte) 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: false Result_3: true Result_4: true