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