Golang bytes.Equal() function example
package bytes
Equal returns a boolean reporting whether the given inputs are the same length and contain the same bytes. A nil argument is equivalent to an empty slice.
Golang bytes.Equal() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
search_input := []byte("abcdefghidefdef")
key_slice := []byte("abc")
key_slice2 := []byte("xyz")
fmt.Println(bytes.Count(search_input,key_slice))
fmt.Println(bytes.Count(search_input,key_slice2))
fmt.Println(bytes.Count(search_input,[]byte("def")))
}
Output :
false
true
true
Advertisement
Something interesting
Tutorials
+12.1k Golang : md5 hash of a string
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+7.5k Golang : Dealing with struct's private part
+6.7k Golang : Check if password length meet the requirement
+22.9k Golang : Gorilla mux routing example
+6.1k Golang : How to write backslash in string?
+5.1k Swift : Convert (cast) Float to Int or Int32 value
+22.7k Golang : Round float to precision example
+8.3k Useful methods to access blocked websites
+32.2k Golang : Convert []string to []byte examples
+5.6k Golang : Shortening import identifier
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)