Standard library / bytes

bytes.TrimRightFunc()

Removes trailing runes satisfying f. The returned slice may alias the input. Expected stdout: '12go\n'.

Formal Syntax & Structure

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

Parameters & Attributes

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

Return Value

[]byte

Removes trailing runes satisfying f. The returned slice may alias the input.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt"  "unicode")
func main() {  fmt.Println(string(bytes.TrimRightFunc([]byte("12go34"), unicode.IsDigit)))}
Go Reference