
6

[Golang] String startswith and endswith
source link: http://siongui.github.io/2017/03/17/go-string-starts-with-ends-with/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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")
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK