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
+7.1k Golang : Get environment variable
+30.4k Golang : Generate random string
+13.4k Golang : Generate Code128 barcode
+25.3k Golang : Convert uint value to string type
+6.3k Golang : How to search a list of records or data structures
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+7.1k Golang : Gorrila mux.Vars() function example
+20.3k Swift : Convert (cast) Int to int32 or Uint32
+8.2k Golang : Metaprogramming example of wrapping a function
+12.3k Golang : How to check if a string starts or ends with certain characters or words?
+6.5k Golang : Map within a map example
+8.3k Golang : Implementing class(object-oriented programming style)