一个逗号引发的语法报错问题:syntax error: unexpected newline, expecting comma or }或者missing ',' before newline in composite literal
代码如下:
func main() { boxes := Boxlist{ Box{4, 4, 4, RED}, Box{5, 5, 5, YELLOW}, Box{6, 6, 6, BLACK}, Box{10, 10, 10, BLUE}, Box{8, 8, 8, WHITE}, // 此处逗号不可省略 115:19: missing ',' before newline in composite literal } func main() { a := map[string]int{ "golang": 2, "python": 1, "java": 3, // syntax error: unexpected newline, expecting comma or } } Println(a) }
实践出真知~