草庐IT

json - golang 使用 Gorm 查询数据库并在 http 响应中返回 json

我是Go的新手,正在使用Gorm查询我的postgres数据库,但我无法以字典格式返回我的数据,其中pokemon的类型用作该类型所有pokemon的数组的键json:cannotunmarshalobjectintoGovalueoftype[]models.Pokemon这是我的代码:typePokemonstruct{Namestring`db:"name"`Typestring`db:"type"`}pokemonTypes:=[6]string{"fire","electric","water","grass",}varretDatastruct{Poke[]Pokemon}