1 回答
TA贡献1783条经验 获得超4个赞
你的 internalstruct
没有在任何地方声明——它们都是匿名类型。要按名称实际显式实例化它们,它们需要存在于某个地方(操场):
package main
import (
"fmt"
)
type SimpleResponse struct {
TextToSpeech string `json:"textToSpeech"`
}
type Item struct {
SimpleResponse SimpleResponse `json:"simpleResponse"`
}
type Suggestion struct {
Title string `json:"title"`
}
type RichResponse struct {
Items []Item `json:"items"`
Suggestions []Suggestion `json:"suggestions"`
}
type Google struct {
ExpectUserResponse bool `json:"expectUserResponse"`
RichResponse RichResponse `json:"richResponse"`
}
type Payload struct {
Google Google `json:"google"`
}
type DialogFlowResponseSuggestion struct {
Payload Payload `json:"payload"`
}
func main() {
in := DialogFlowResponseSuggestion{
Payload: Payload{
Google: Google{
ExpectUserResponse: true,
RichResponse: RichResponse{
Items: []Item{
Item{SimpleResponse: SimpleResponse{dialog.MReturn.Message}},
},
Suggestions: []Suggestion{
Suggestion{Title: "Suggestion Chips"},
Suggestion{Title: "suggestion 1"},
Suggestion{Title: "suggestion 2"},
},
},
},
},
}
fmt.Println(in)
}
- 1 回答
- 0 关注
- 90 浏览
添加回答
举报