[Golang] String startswith and endswith
Go equivalent of Python string startswith and endswith methods.
Actually strings package in Go standard library already provides these two methods, but with different names. HasPrefix is Go's string startswith, and HasSuffix is Go's string endswith.
Go String starts with
import "strings"
// true
strings.HasPrefix("Gopher", "Go")
Go String ends with
import "strings"
// true
strings.HasSuffix("Amigo", "go")
References:
[1] | func HasPrefix - strings - The Go Programming Language |
[2] | func HasSuffix - strings - The Go Programming Language |