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
+9.9k Golang : Function wrapper that takes arguments and return result example
+6.9k Nginx : Password protect a directory/folder
+10.1k Golang : Get login name from environment and prompt for password
+16.9k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+9.5k Golang : Convert(cast) string to int64
+4.7k JavaScript: Add marker function on Google Map
+8.4k Golang : How to check if input string is a word?
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+10.5k Swift : Convert (cast) String to Integer
+9.7k Golang : interface - when and where to use examples
+8.8k Yum Error: no such table: packages
+16.5k Golang : Execute terminal command to remote machine example