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
+7.4k Golang : Convert source code to assembly language
+17.6k Convert JSON to CSV in Golang
+6.3k Javascript : Generate random key with specific length
+7.8k Golang : Scan files for certain pattern and rename part of the files
+7.1k Nginx : How to block user agent ?
+51.1k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+4.9k Nginx and PageSpeed build from source CentOS example
+7.9k Golang Hello World Example
+17.6k Golang : Parse date string and convert to dd-mm-yyyy format
+13k Golang : Calculate elapsed years or months since a date
+25.8k Golang : Daemonizing a simple web server process example
+7.5k Golang : How to handle file size larger than available memory panic issue