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
+43.2k Golang : Convert []byte to image
+7.6k Javascript : Push notifications to browser with Push.js
+10.9k Golang : Get UDP client IP address and differentiate clients by port number
+5.6k PHP : Fix Call to undefined function curl_init() error
+19.5k Golang : How to Set or Add Header http.ResponseWriter?
+30.4k Golang : Generate random string
+4.6k Mac OSX : Get disk partitions' size, type and name
+5.9k Golang : Denco multiplexer example
+33k Golang : How to check if a date is within certain range?
+14k Golang : Google Drive API upload and rename example
+19.9k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+15.2k Golang : How to add color to string?