Golang bytes.TrimSuffix() function example
package bytes
TrimPrefix returns the input slice without the provided trailing suffix string(2nd parameter). If the given input slice doesn't start with suffix, the original input slice is returned unchanged.
Golang bytes.TrimSuffix() function usage example
package main
import (
"fmt"
"bytes"
)
func main() {
str := []byte("Bye Bye!")
trimmed := bytes.TrimSuffix(str,[]byte("Bye!"))
fmt.Println(string(trimmed))
fmt.Println(string(trimmed) + "Dear!")
}
Output :
Bye
Bye Dear!
Reference :
Advertisement
Something interesting
Tutorials
+8.8k Golang : On lambda, anonymous, inline functions and function literals
+10.3k Golang : Embed secret text string into binary(executable) file
+6.7k Golang : Output or print out JSON stream/encoded data
+13.6k Golang : Query string with space symbol %20 in between
+6.8k Golang : Get expvar(export variables) to work with multiplexer
+7.3k Golang : alternative to os.Exit() function
+6.7k Golang : When to use make or new?
+7.6k Android Studio : AlertDialog to get user attention example
+13.8k Golang : unknown escape sequence error
+7.9k Golang : Trim everything onward after a word
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+14.4k Golang : Parsing or breaking down URL