I'm writing an api server using flutter and Go Echo framework, I want to send data from flutter to Go and save it, but c.bind()
doesn't work in Go:
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
}
Create a structure as in the code above, and bind it as shown below:
d := &echo.DefaultBinder{}
var aa _getData
d.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 [] []}
The pages and tags data are not bound. Other fields are bound, but why not just the multiarray field? How can I bind? I'm a beginner, any advice would be appreciated.