package maptostruct import ( "fmt" "key_performance_indicators/overall/publicmethod" "github.com/gin-gonic/gin" ) //map 装 struct 实验 func (a *ApiMethod) MapToStructShiyan(c *gin.Context) { mapShiyan := map[string]string{ "name": "秦东", "age": "1", "time": "456313", "time1": "45631321654654", "time2": "4.5631321654654", "time3": "45.631321654654", } var shiyanVal shiyanType err := publicmethod.MapToStruct(mapShiyan, &shiyanVal, "json") if err != nil { publicmethod.Result(1, err.Error(), c) return } fmt.Printf("shiyanType---->%v\n", shiyanVal) publicmethod.Result(0, shiyanVal, c) }