Standard library / strings
strings.HasSuffix()
Reports whether the input ends with the literal suffix. Empty suffix matches. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func HasSuffix(s, suffix string) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text or sequence. |
| suffix | string | Trailing sequence to match. |
Return Value
bool
Reports whether the input ends with the literal suffix. Empty suffix matches.
Working Example
Example Snippetgo
package main
import ( "fmt" "strings")
func main() { fmt.Println(strings.HasSuffix("report.csv", ".csv"))}