Golang bytes.TrimFunc() function example
package bytes
TrimFunc returns a subslice of the input slice by slicing off all leading and trailing UTF-8-encoded Unicode code points that satisfy the inner filter function(2nd parameter).
Golang bytes.TrimFunc() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
str := []byte("abcdefghijk")
inner_func := func(r rune) bool {
return r <= 'c' || r >= 'i'
}
fmt.Println(string(bytes.TrimFunc(str,inner_func)))
}
Output :
defgh
Reference :
Advertisement
Something interesting
Tutorials
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+9.8k Golang : Qt get screen resolution and display on center example
+9.9k Golang : Turn string or text file into slice example
+15.6k Golang : Get checkbox or extract multipart form data value example
+13.8k Generate salted password with OpenSSL example
+5.6k Swift : Get substring with rangeOfString() function example
+21.8k Golang : Convert string slice to struct and access with reflect example
+6.4k Golang : Handling image beyond OpenCV video capture boundary
+6k PHP : How to check if an array is empty ?
+15.4k Golang : Find location by IP address and display with Google Map
+18.2k Golang : Get path name to current directory or folder