我正在使用顫振和Go Echo框架編寫一個api服務器,我想從顫動到Go發送數據并保存它,但在Go中不起作用:c.bind()type _getData struct { Title string `json:"title" form:"title"` Address string `json:"address" form:"address"` Location string `json:"location" form:"location"` MapId uint `json:"map_id" form:"map_id"` Date _customTime `json:"date" form:"date"` Pages []struct { Order int `json:"order" form:"order"` Description string `json:"description" form:"description"` } `json:"pages" form:"pages"` Tags []struct { TagName string `json:"tag_name" form:"tag_name"` ID string `json:"id" form:"id"` } `json:"tags" form:"tags"`}type _customTime struct { time.Time}創建一個結構,如上面的代碼所示,并按如下所示進行綁定:d := &echo.DefaultBinder{}var aa _getDatad.Bind(&aa, c)fmt.Println(c.Request().Form)fmt.Println(aa)----- fmt.Println(c.Request().Form)'s result is -----ap[address:[?? ????? ????? ??? ???? ] date:[2021-10-01] location: [37.330672396748554 -122.03014377504589] pages[0][description]:[123123] pages[0] [order]:[0] tags[0][tag_name]:[sdf] title:[123123]]----- fmt.Println(aa)'s result is -----{123123 ?? ????? ????? ??? ???? 37.330672396748554 -122.03014377504589 0 2021-10-01 00:00:00 +0900 KST [] []}頁面和標記數據未綁定。其他字段是綁定的,但為什么不只是多數組字段?如何綁定?我是初學者,任何建議將不勝感激。
1 回答

POPMUISE
TA貢獻1765條經驗 獲得超5個贊
Echo 框架不支持從現成的表單數據綁定數組。
您可以改用 json 或使用第三方庫。查看實施或發布和 github 問題 https://github.com/labstack/echo/issues/1644
- 1 回答
- 0 關注
- 139 瀏覽
添加回答
舉報
0/150
提交
取消