Standard library / strings
strings.LastIndex()
Returns the byte offset of the last exact occurrence, or -1. Expected stdout: '2\n'.
Formal Syntax & Structure
go syntaxgo
func LastIndex(s, substr string) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text or sequence. |
| substr | string | Substring to search for. |
Return Value
int
Returns the byte offset of the last exact occurrence, or -1.
Working Example
Example Snippetgo
package main
import ( "fmt" "strings")
func main() { fmt.Println(strings.LastIndex("aba", "a"))}