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
+14.4k Golang : How to convert a number to words
+9.3k Golang : How to get username from email address
+13.1k Golang : List objects in AWS S3 bucket
+5k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+11.5k Use systeminfo to find out installed Windows Hotfix(s) or updates
+9.3k Golang : How to get garbage collection data?
+9.8k Golang : Qt get screen resolution and display on center example
+18.5k Golang : Example for RSA package functions
+32.7k Golang : Regular Expression for alphanumeric and underscore
+12k Golang : Decompress zlib file example
+12.1k Golang : Perform sanity checks on filename example
+13.7k Golang : Image to ASCII art example