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
+9k Golang : Inject/embed Javascript before sending out to browser example
+19.9k Golang : Measure http.Get() execution time
+15.4k Golang : Find location by IP address and display with Google Map
+6k Golang : Compound interest over time example
+18.4k Golang : How to remove certain lines from a file
+7.1k Nginx : How to block user agent ?
+11.8k Golang : Verify Linux user password again before executing a program example
+13.6k Android Studio : Password input and reveal password example
+8.9k Golang : GMail API create and send draft with simple upload attachment example
+8.8k Golang : Take screen shot of browser with JQuery example
+10.7k Golang : Get currencies exchange rates example
+6.1k Golang : Debug with Godebug