Golang bytes.Contains() function example
package bytes
Contains reports whether subslice is within search input.
Golang bytes.Contains() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
search_input := []byte("abcdefghi")
key_slice := []byte("abc")
key_slice2 := []byte("xyz")
fmt.Println(bytes.Contains(search_input,key_slice))
fmt.Println(bytes.Contains(search_input,key_slice2))
}
Output :
true
false
Advertisement
Something interesting
Tutorials
+12.7k Android Studio : Highlight ImageButton when pressed on example
+12.7k Golang : Pass database connection to function called from another package and HTTP Handler
+17.3k Golang : How to tell if a file is compressed either gzip or zip ?
+6.1k Golang : How to write backslash in string?
+12.4k Golang : Encrypt and decrypt data with x509 crypto
+12.2k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+9.9k Golang : Check if user agent is a robot or crawler example
+8.3k Golang : Implementing class(object-oriented programming style)
+19.3k Golang : Get host name or domain name from IP address
+7.7k Gogland : Where to put source code files in package directory for rookie
+13.2k Golang : How to calculate the distance between two coordinates using Haversine formula
+10.6k Golang : How to delete element(data) from map ?