golang 字符串/string 判断字符串开头 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import ( "fmt" "strings" ) func main() { myString := "www.topgoer.com" // Option 1: (Recommended) if strings.HasPrefix(myString, "www") { fmt.Println("Hello to you too") } else { fmt.Println("Goodbye") } } go, string, join 1 2 3 4 5