Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的 GET 方法,问题是我在 json 中得到的只是一个用户,而不是我的数据库中有 3 个用户。
func GetUsers(c *gin.Context) { var users = db.Find(&models.Person{}) c.JSON(200, users) }
Try this:
func GetUsers(c *gin.Context) { users := []models.Person{} db.Find(&users) c.JSON(200, &users) }