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
+9.1k Golang : Get curl -I or head data from URL example
+10.8k Golang : Natural string sorting example
+8.2k Golang : Reverse text lines or flip line order example
+8.2k Golang : Routes multiplexer routing example with regular expression control
+16.4k Golang : Send email and SMTP configuration example
+4.9k Python : Find out the variable type and determine the type with simple test
+6k Golang : Function as an argument type example
+12.5k Golang : Forwarding a local port to a remote server example
+13.4k Golang : Verify token from Google Authenticator App
+9.3k Golang : How to get username from email address
+10.3k Golang : Wait and sync.WaitGroup example
+15.3k nginx: [emerg] unknown directive "ssl"