Golang bytes.HasSuffix() function example
package bytes
HasSuffix tests whether the input byte slice ends with suffix.
Golang bytes.HasSuffix() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
str := []byte("abcdef")
fmt.Println(bytes.HasSuffix(str, []byte("abc")))
fmt.Println(bytes.HasSuffix(str, []byte("bcd")))
fmt.Println(bytes.HasSuffix(str, []byte("def")))
}
Output :
false
false
true
Note :
Suffix = something added to the end of something else.
See also : Golang bytes.HasPrefix() function example
Advertisement
Something interesting
Tutorials
+13.1k Golang : How to get a user home directory path?
+13k Swift : Convert (cast) Int to String ?
+25.3k Golang : Convert uint value to string type
+12.7k Golang : Remove or trim extra comma from CSV
+38.1k Golang : Read a text file and replace certain words
+10k Golang : Get escape characters \u form from unicode characters
+5.2k Golang : Calculate half life decay example
+6.5k Golang : Spell checking with ispell example
+20.7k Golang : Saving private and public key to files
+4.7k Adding Skype actions such as call and chat into web page examples
+4.7k JavaScript: Add marker function on Google Map