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