Standard library / bytes

bytes.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 []byte) bool

Parameters & Attributes

NameTypeDescription
s[]byteInput text or sequence.
suffix[]byteTrailing 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 (  "bytes"  "fmt")
func main() {  fmt.Println(bytes.HasSuffix([]byte("report.csv"), []byte(".csv")))}
Go Reference