Golang bytes.TrimPrefix() function example
package bytes
TrimPrefix returns the input slice without the provided leading prefix string(2nd parameter). If the given input slice doesn't start with prefix, the original input slice is returned unchanged.
Golang bytes.TrimPrefix() function usage example
package main
import (
"fmt"
"bytes"
)
func main() {
str := []byte("Bye Bye!")
trimmed := bytes.TrimPrefix(str,[]byte("Bye"))
fmt.Println(string(trimmed))
fmt.Println("Good " + string(trimmed))
}
Output :
Bye!
Good Bye!
Reference :
Advertisement
Something interesting
Tutorials
+9.8k Golang : Resumable upload to Google Drive(RESTful) example
+8.3k Swift : Convert (cast) Character to Integer?
+6k Golang : Experimenting with the Rejang script
+33.7k Golang : All update packages with go get command
+31.1k Golang : Calculate percentage change of two values
+5.2k Golang : Print instead of building pyramids
+6.8k Get Facebook friends working in same company
+23.6k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+14.3k Golang : Recombine chunked files example
+7.8k Golang : Reverse a string with unicode
+32.2k Golang : Convert []string to []byte examples
+5.2k Golang : Experimental Jawi programming language