Standard library / bytes

bytes.LastIndexFunc()

Returns the byte offset of the last rune accepted by f, or -1. Expected stdout: '3\n'.

Formal Syntax & Structure

go syntaxgo
func LastIndexFunc(s []byte, f func(r rune) bool) int

Parameters & Attributes

NameTypeDescription
s[]byteInput text or sequence.
ffunc(r rune) boolPredicate over decoded runes.

Return Value

int

Returns the byte offset of the last rune accepted by f, or -1.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt"  "unicode")
func main() {  fmt.Println(bytes.LastIndexFunc([]byte("1é2"), unicode.IsDigit))}
Go Reference