syntax error: unexpected newline, expecting comma or } syntax error: unexpected newline, expecting comma or } 2019 年 11 月 19 日 北漂小兄弟 Comments 0 Comment 程序会如何编译? func main() { fruit := []string{ "apple", "banana", "cherry" } fmt.Println(fruit) } 就会触发上面标题的错误,原因是切片的最后一个元素cherry后面没有逗号, 在多行切片,数组或MAP中,每行必须以逗号结尾。 打赏赞(1)分享