Standard library / bytes

bytes.LastIndexByte()

Returns the offset of the last matching byte, or -1. Expected stdout: '2\n'.

Formal Syntax & Structure

go syntaxgo
func LastIndexByte(s []byte, c byte) int

Parameters & Attributes

NameTypeDescription
s[]byteInput text or sequence.
cbyteByte to match or special case mapping, according to type.

Return Value

int

Returns the offset of the last matching byte, or -1.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  fmt.Println(bytes.LastIndexByte([]byte("aba"), 'a'))}
Go Reference