converting argument $6 type: unsupported type []string, a slice of string

//psot接受传递的参数,post receives the passed parameters,
	type postParam struct {
		Img     []string `json:"img"`
		Content string   `json:"content" binding:"required"`
	var param postParam
	if err := c.ShouldBindJSON(&param); err != nil {
		utils.ReturnData(c, http.StatusOK, map[string]interface{}{
			"response": fail(""),
//Convert to json array
img_json, _ := json.Marshal(param.Img)
//save to database,保存到数据库
type AddDynamic struct {
	ID         int    `json:"id"`
	Img        string `gorm:"column:img" json:"img"`
	var addDynamic models.AddDynamic
	addDynamic.Img = string(img_json)

Leave a Reply

Your email address will not be published. Required fields are marked *