Golang bytes.TrimLeft() function example
package bytes
TrimLeft returns a subslice of the input slice by slicing off all leading UTF-8-encoded Unicode code points contained in the filter set (2nd parameter)
Golang bytes.TrimLeft() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
str := []byte("abcdefg")
trimmed := bytes.TrimLeft(str, "ab")
fmt.Println(string(trimmed))
testtrim := bytes.TrimLeft(str, "fg")
fmt.Println(string(testtrim)) // will not work
}
Output :
cdefg
abcdefg
Reference :
Advertisement
Something interesting
Tutorials
+6.5k Golang : Combine slices of complex numbers and operation example
+6.8k Swift : substringWithRange() function example
+20k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+21.4k Curl usage examples with Golang
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+4.1k Javascript : Empty an array example
+8.6k Android Studio : Import third-party library or package into Gradle Scripts
+13.5k Facebook PHP getUser() returns 0
+15.4k Golang : invalid character ',' looking for beginning of value
+6.5k Golang : Handling image beyond OpenCV video capture boundary
+20.5k nginx: [emerg] unknown directive "passenger_enabled"
+5.2k Golang : Convert lines of string into list for delete and insert operation