Golang bytes.TrimLeftFunc() function

package bytes

TrimLeftFunc returns a subslice of the input slice by slicing off all leading UTF-8-encoded Unicode code points that satisfy the inner filter function(2nd parameter).

Golang bytes.TrimLeftFunc() function usage example

 package main

 import (
 "bytes"
 "fmt"
 )

 func main() {

 str := []byte("abcdefghijk")

 inner_func := func(r rune) bool {
 return r <= 'c'
 }

 fmt.Println(string(bytes.TrimLeftFunc(str,inner_func)))

 }

Output :

defghijk

Reference :

http://golang.org/pkg/bytes/#TrimLeftFunc

  See also : Golang bytes.TrimRightFunc() function example

Advertisement