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) bool

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.
suffixstringTrailing 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"))}
Go Reference