Golang bytes.TrimRightFunc() function example
package bytes
TrimRightFunc returns a subslice of the input slice by slicing off all trailing UTF-8-encoded Unicode code points that satisfy the inner filter function(2nd parameter).
Golang bytes.TrimRightFunc() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
str := []byte("abcdefghijk")
inner_func := func(r rune) bool {
return r >= 'f'
}
fmt.Println(string(bytes.TrimRightFunc(str,inner_func)))
}
Output :
abcde
Reference :
See also : Golang bytes.TrimLeftFunc() function
Advertisement
Something interesting
Tutorials
+8.3k Swift : Convert (cast) Character to Integer?
+7.3k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+20k Golang : How to run your code only once with sync.Once object
+8.3k Golang : Configure Apache and NGINX to access your Go service example
+6k Golang : Function as an argument type example
+12.9k Python : Convert IPv6 address to decimal and back to IPv6
+6k Golang : Compound interest over time example
+33.6k Golang : How to check if slice or array is empty?
+4.6k MariaDB/MySQL : How to get version information
+14.2k Golang : Fix image: unknown format error
+9.7k Golang : Find correlation coefficient example