草庐IT

PrintAnonymous

全部标签

go - 以匿名结构作为参数导出函数[不能在 package.Func 的参数中使用值(类型 struct {...})作为类型 struct {...}]

这是一段代码play.google.org运行没有任何问题:packagemainimport("fmt")funcPrintAnonymous(vstruct{iintsstring}){fmt.Printf("%d:%s\n",v.i,v.s)}funcPrintAnonymous2(vstruct{}){fmt.Println("Whatever")}funcmain(){value:=struct{iintsstring}{0,"Hello,world!",}PrintAnonymous(value)PrintAnonymous2(struct{}{})}但是,如果PrintA

go - 以匿名结构作为参数导出函数[不能在 package.Func 的参数中使用值(类型 struct {...})作为类型 struct {...}]

这是一段代码play.google.org运行没有任何问题:packagemainimport("fmt")funcPrintAnonymous(vstruct{iintsstring}){fmt.Printf("%d:%s\n",v.i,v.s)}funcPrintAnonymous2(vstruct{}){fmt.Println("Whatever")}funcmain(){value:=struct{iintsstring}{0,"Hello,world!",}PrintAnonymous(value)PrintAnonymous2(struct{}{})}但是,如果PrintA