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
+15.3k Golang : Get all local users and print out their home directory, description and group id
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+7.3k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+14k Golang : Google Drive API upload and rename example
+6.8k Golang : Join lines with certain suffix symbol example
+6.3k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+9.7k Golang : Format strings to SEO friendly URL example
+15.9k Golang : Read a file line by line
+24.5k Golang : GORM read from database example
+6.7k Golang : Humanize and Titleize functions
+14.4k Android Studio : Use image as AlertDialog title with custom layout example
+7.6k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image