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
+17.7k How to enable MariaDB/MySQL logs ?
+23.2k Golang : Print out struct values in string format
+14.9k Golang : How to check for empty array string or string?
+34k Golang : Proper way to set function argument default value
+46.2k Golang : Read tab delimited file with encoding/csv package
+10.6k Android Studio : Simple input textbox and intercept key example
+44.9k Golang : Use wildcard patterns with filepath.Glob() example
+13.9k Golang : Get current time
+29.5k Golang : How to create new XML file ?
+15.4k Golang : Find location by IP address and display with Google Map
+13.4k Golang : Read from buffered reader until specific number of bytes