In Go language, strings are different from other languages like Java, C++, Python, etc. It is a sequence of variable-width characters where each and every character is represented by one or more bytes using UTF-8 Encoding.
In Go strings, you can check whether the string ends with the specified suffix or not with the help of HasSuffix() function. This function returns true if the given string ends with the specified suffix and return false if the given string does not end with the specified suffix. It is defined under the strings package so, you have to import strings package in your program for accessing HasSuffix function.
func HasSuffix(str, suf string) bool
Here, str is the original string and suf is a string which represents the suffix. The return type of this function is of the bool type.
Result 1: true Result 2: true Result 3: false Result 4: true Result 5: false Result 6: true Result 7: false