Go &引用;复合文字“中缺少类型”;错误
在执行此Go程序时,我遇到以下错误。不知道我错过了什么Go &引用;复合文字“中缺少类型”;错误,go,Go,在执行此Go程序时,我遇到以下错误。不知道我错过了什么 .\m.go:28: missing type in composite literal .\m.go:28: too few values in struct initializer 主程序包 进口( “fmt” ) LI型结构{ Id int`json:“Id”` } 类型TP结构{ 名称字符串`json:“名称”` 值字符串`json:“值”` } 类型LTI结构{ Leads[]LI`json:“Leads”` 令牌[]TP`j
.\m.go:28: missing type in composite literal
.\m.go:28: too few values in struct initializer
主程序包
进口(
“fmt”
)
LI型结构{
Id int`json:“Id”`
}
类型TP结构{
名称字符串`json:“名称”`
值字符串`json:“值”`
}
类型LTI结构{
Leads[]LI`json:“Leads”`
令牌[]TP`json:“令牌,省略空”`
}
类型RCR结构{
输入LTI`json:“输入”`
}
func main(){
fmt.Println(“你好,游乐场”)
leadinput:=LI{Id:55213}
leadTokensInput:=LTI{{[]LI{leadIdInput},nil}
rCR:=rCR{Input:leadTokensInput}
fmt.Println(“rCR为“%+v”,rCR.Input.Leads[0])
}
请帮助。使用
LTI{Leads: []LI{leadIdInput}}
及
试穿一下:
输出:
Hello, playground
rCR is '{Id:55213}'
使用
及
试穿一下:
输出:
Hello, playground
rCR is '{Id:55213}'
@skm我希望这有帮助。@skm我希望这有帮助。
Hello, playground
rCR is '{Id:55213}'