Standard library / bytes

bytes.TrimRight()

Removes trailing runes in cutset; stops at the first nonmember. The returned slice may alias the input. Expected stdout: '.go\n'.

Formal Syntax & Structure

go syntaxgo
func TrimRight(s []byte, cutset string) []byte

Parameters & Attributes

NameTypeDescription
s[]byteInput text or sequence.
cutsetstringSet of code points to remove from the indicated ends.

Return Value

[]byte

Removes trailing runes in cutset; stops at the first nonmember. The returned slice may alias the input.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  fmt.Println(string(bytes.TrimRight([]byte(".go.."), ".")))}
Go Reference