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) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | []byte | Input text or sequence. |
| f | func(r rune) bool | Predicate 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)))}