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 :
See also : Golang bytes.TrimRightFunc() function example
Advertisement
Something interesting
Tutorials
+11.3k Golang : Characters limiter example
+12.1k Golang : Detect user location with HTML5 geo-location
+16.3k Golang :Trim white spaces from a string
+5.2k Golang : PGX CopyFrom to insert rows into Postgres database
+5.3k Golang : How to deal with configuration data?
+11.2k Golang : Proper way to test CIDR membership of an IP 4 or 6 address example
+5.8k Golang : List all packages and search for certain package
+10.6k Golang : Resolve domain name to IP4 and IP6 addresses.
+12.3k Golang : Validate email address
+30k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+6k Golang : Convert Chinese UTF8 characters to Pin Yin
+8.3k Golang : Oanda bot with Telegram and RSI example