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
+13.3k Golang : Linear algebra and matrix calculation example
+7.7k Golang : Error reading timestamp with GORM or SQL driver
+9.7k PHP : Get coordinates latitude/longitude from string
+6.6k Golang : How to determine if request or crawl is from Google robots
+36.3k Golang : How to split or chunking a file to smaller pieces?
+7.8k Golang : Lock executable to a specific machine with unique hash of the machine
+10.6k Golang : ISO8601 Duration Parser example
+11.6k Golang : Simple file scaning and remove virus example
+11.6k Golang : Fuzzy string search or approximate string matching example
+8.7k Golang : Find duplicate files with filepath.Walk
+11.2k Golang : Proper way to test CIDR membership of an IP 4 or 6 address example
+18.6k Golang : Generate thumbnails from images