Golang bytes.IndexByte() function example
package bytes
IndexByte returns the index of the first instance of search key in search input. In case search key was not found in search input. It returns -1.
Golang bytes.IndexByte() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
fmt.Println(bytes.IndexByte([]byte("abcdef"), '5')) // return -1
fmt.Println(bytes.IndexByte([]byte("abcdef"), 'd')) // return index num of d..remember index start from 0
}
Output :
-1
3
Reference :
Advertisement
Something interesting
Tutorials
+11.4k Golang : Delay or limit HTTP requests example
+30k Golang : Get time.Duration in year, month, week or day
+11.7k Golang : Gorilla web tool kit secure cookie example
+10.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+10.7k Golang : Get currencies exchange rates example
+10k Golang : Convert octal value to string to deal with leading zero problem
+18.4k Golang : How to remove certain lines from a file
+14.6k Golang : Execute function at intervals or after some delay
+12.7k Golang : Sort and reverse sort a slice of bytes
+5.5k Golang : Stop goroutine without channel
+4.7k Linux/MacOSX : How to symlink a file?
+5.6k Golang : Frobnicate or tweaking a string example