strings.LastIndexByte() Function in Golang With Examples Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report strings.LastIndexByte() Function in Golang returns the index of the last instance of the given byte in the original string. If the given byte is not available in the original string, then this method will return -1. Syntax: func LastIndexByte(str string, b byte) int Here, str is the original string and b is a byte, whose we want to find the last index value. Return Value: It returns the integer. Example 1: C // Golang program to illustrate the // strings.LastIndexByte() Function package main // importing fmt and strings import ( "fmt" "strings" ) // calling main method func main() { // returns the last index of 'g' in string. fmt.Println(strings.LastIndexByte("geeksforgeeks", 'g')) // returns the last index of 'k' in string. fmt.Println(strings.LastIndexByte("geekgeekgeek", 'k')) } Output: 8 11 Example 2: C // Golang program to illustrate the // strings.LastIndexByte() Function package main // importing fmt and strings import ( "fmt" "strings" ) // calling main method func main() { // performs case-insensitive search(returns -1). fmt.Println(strings.LastIndexByte("GeeksForGeeks", 'g')) // performs case-insensitive search(returns -1). fmt.Println(strings.LastIndexByte("GeeKGeeKGeeK", 'k')) } Output: -1 -1 Comment More infoAdvertise with us Next Article strings.LastIndexByte() Function in Golang With Examples P PranchalKatiyar Follow Improve Article Tags : Go Language Golang-String Similar Reads strings.LastIndex() Function in Golang With Examples strings.LastIndex() function in the Golang returns the starting index of the occurrence of the last instance of a substring in a given string. If the substring is not found then it returns -1. Thus, this function returns an integer value. The index is counted taking zero as the starting index of the 2 min read strings.IndexByte() Function in Golang With Examples strings.IndexByte() Function in Golang returns the index of the first instance of the given byte in the original string. If the given byte is not available in the original string, then this method will return -1. Syntax: func IndexByte(str string, b byte) int Here, str is the original string and b i 1 min read strings.LastIndexAny() Function in Golang With Examples strings.LastIndexAny() Function in the Golang is used to find the index of the last instance of any Unicode code point from chars in a given string. If the Unicode code point from chars is not found then it returns -1. Thus, this function returns an integer value. The index is counted taking zero as 2 min read strings.LastIndexFunc() Function in Golang With Examples strings.LastIndexFunc() Function in Golang returns the index of string s of the last Unicode code point, which satisfies func(c), or it returns -1 if no matches found. Syntax: func LastIndexFunc(s string, f func(rune) bool) int Here, s is the string and func() is a function. Return Value: It returns 1 min read strings.Index() Function in Golang With Examples strings.Index() Function in Golang is used to get the first instance of a specified substring. If the substring is not found, then this method will return -1. Syntax: func Index(str, sbstr string) int Here, str is the original string and sbstr is a string whose we want to find index value. Example 1 2 min read strings.IndexAny() Function in Golang With Examples strings.IndexAny() Function in Golang is used to returns the index of the first instance of any Unicode code point from chars in the original string. If the Unicode code point from chars is not available in the original string, then this method will return -1. Syntax: func IndexAny(str, charstr stri 2 min read strings.IndexRune() Function in Golang With Examples strings.IndexRune() Function in Golang is used to find the first index of the specified rune in the given string. It is defined under the string package so, you have to import string package in your program for accessing IndexRune function Syntax: func IndexRune(str string, r rune) int This function 2 min read strings.IndexFunc() Function in Golang With Examples strings.IndexFunc() Function in Golang is used to returns the index into s of the first Unicode code point satisfying f(c), or -1 if none do. Syntax: func IndexFunc(str string, f func(rune) bool) int Here, str is string which may contain Unicode code point and f is func which validates the Unicode p 1 min read strings.SplitN() Function in Golang with Examples strings.SplitN() Function() is a string manipulation function in Go language. It is used to split a given string into substrings separated by a separator. This function returns the slices of all substrings between those separators. Syntax: func SplitN(s, sep string, n int) []string Here, s is the st 3 min read strings.Join() Function in Golang With Examples strings.Join() Function in Golang concatenates all the elements present in the slice of string into a single string. This function is available in the string package. Syntax: func Join(s []string, sep string) string Here, s is the string from which we can concatenate elements and sep is the separato 1 min read Like