0
鉴于以下代码:使用地图[字符串]接口{}:
type Message struct {
Params map[string]interface{} `json:"parameters"`
Result interface{} `json:"result"`
}
func (h Handler) Product(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
msg := &Message{
Action: "get_products",
Params: {
"id1": val1,
"id2": val2,
},
}
h.route(msg)
}
的想法是能够发送一个未知量的一个块ID1 => VAL1,ID2 => val2的...到路由。
它给了我这个错误:
missing type in composite literal
它是一个错字,你的'Action'应是“结果”?或者它是你忘记在结构中定义的字段? – nevets