匿名结构无法使用复合文字进行编译

anonymous struct fail to compile with composite literal

只需两行代码:

var v4 interface{}=strcut{x int}(1) // line 14
var v5 interface{}=&strcut{x int}(1) // line 15

去打印:

my_test.go:14:29: missing ',' in composite literal
my_test.go:15:30: missing ',' in composite literal

那么如何解决呢?非常感谢。

初始化匿名结构时,必须初始化该结构的成员字段:

var v4 interface{}=struct{x int}{x:1} // line 14
var v5 interface{}=&struct{x int}{x:1} // line 15