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
+20.6k Nginx + FastCGI + Go Setup.
+7k Web : How to see your website from different countries?
+5.4k Golang : Return multiple values from function
+3.7k Java : Random alphabets, alpha-numeric or numbers only string generator
+12.6k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+5.6k Golang : Shortening import identifier
+29.9k Golang : How to get HTTP request header information?
+11.7k Golang : How to detect a server/machine network interface capabilities?
+13.5k Golang : How to get year, month and day?
+5.9k Golang : Shuffle array of list
+9.1k Golang : Get curl -I or head data from URL example