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
+8.8k Golang : Heap sort example
+7k Golang : Gargish-English language translator
+17k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+7.7k Golang : How to execute code at certain day, hour and minute?
+35.3k Golang : Strip slashes from string example
+18k Golang : How to log each HTTP request to your web server?
+10.5k Golang : Select region of interest with mouse click and crop from image
+6.8k Golang : Get expvar(export variables) to work with multiplexer
+22.1k Golang : Match strings by wildcard patterns with filepath.Match() function
+7.5k Golang : Create zip/ePub file without compression(use Store algorithm)
+52.6k Golang : How to get struct field and value by name
+9.5k Mac OSX : Get a process/daemon status information