Just curious to findout: why aren't there standard functions like startswith, endswith, etc as part of the standard libraries in the Go programming language?
转载于:https://stackoverflow.com/questions/13244048/no-startswith-endswith-functions-in-go
The strings package contains HasPrefix and HasSuffix.
import "strings" startsWith := strings.HasPrefix("prefix", "pre") // true endsWith := strings.HasSuffix("suffix", "fix") // true
play.golang.org