Golang bytes.EqualFold() function example
package bytes
EqualFold reports whether the given inputs, interpreted as UTF-8 strings, are equal under Unicode case-folding.
Golang bytes.EqualFold() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
slice1 := []byte("世界")
slice2 := []byte("xyz")
slice3 := []byte("世界")
fmt.Println(bytes.EqualFold(slice1, slice2))
fmt.Println(bytes.EqualFold(slice1, slice3))
fmt.Println(bytes.EqualFold(slice2,[]byte("XYZ"))) // big cap and small cap
}
Output :
false
true
true
Reference :
Advertisement
Something interesting
Tutorials
+25.3k Golang : Convert uint value to string type
+24.1k Golang : Upload to S3 with official aws-sdk-go package
+14.5k Golang : Rename directory
+15.6k Golang : rune literal not terminated error
+18.5k Golang : Set, Get and List environment variables
+16.6k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
+24.5k Golang : Change file read or write permission example
+11.8k Golang : convert(cast) float to string
+8.2k Golang : Metaprogramming example of wrapping a function
+7.9k Golang Hello World Example
+14.8k Golang : Find commonalities in two slices or arrays example
+29.5k Golang : How to create new XML file ?