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) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | []byte | Input text or sequence. |
| suffix | []byte | 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 ( "bytes" "fmt")
func main() { fmt.Println(bytes.HasSuffix([]byte("report.csv"), []byte(".csv")))}