HUGO
Menu
GitHub 90314 stars Mastodon

strings.TrimSuffix

Returns the given string, removing the suffix from the end of the string.
Syntax
strings.TrimSuffix SUFFIX STRING
Returns
string

Usage

The strings.TrimSuffix function returns the given string, removing the suffix from the end of the string. If STRING does not end with SUFFIX, the function returns STRING unchanged.

Examples

{{ strings.TrimSuffix "a" "aabbaa" }} → aabba
{{ strings.TrimSuffix "aa" "aabbaa" }} → aabb
{{ strings.TrimSuffix "aaa" "aabbaa" }} → aabbaa