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
+16.9k Golang : How to generate QR codes?
+4.6k Linux : sudo yum updates not working
+11.6k Golang : Display a text file line by line with line number example
+15.9k Golang : Get current time from the Internet time server(ntp) example
+5.5k Golang : Display advertisement images or strings on random order
+6.9k Fix sudo yum hang problem with no output or error messages
+26.3k Golang : Calculate future date with time.Add() function
+20.6k Golang : Secure(TLS) connection between server and client
+5.4k Unix/Linux : How to archive and compress entire directory ?
+16k Golang : Get sub string example
+7.3k Golang : How to iterate a slice without using for loop?
+6.3k Golang : Selection sort example