labstack / echox

Echo cookbook and website
https://echo.labstack.com
MIT License
411 stars 284 forks source link

Error On CRUD Cookbook #135

Open jung-jin-lee opened 4 years ago

jung-jin-lee commented 4 years ago

https://echo.labstack.com/cookbook/crud

I try to CRUD Cookbook. And I found two points to fix. (※1. line 19, 2. line 45) Can I fix it?

1. [AS-IS] var ( users = map[int]*u*ser{} seq = 1 ) [TO-BE] var ( users = map[int]U**ser{} seq = 1 )

2. [AS-IS] func updateUser(c echo.Context) error { u := new(user) if err := c.Bind(u); err != nil { return err } id, := strconv.Atoi(c.Param("id")) users[id].Name = u.Name return c.JSON(http.StatusOK, users[id]) } [TO-BE] func updateUser(c echo.Context) error { u := new(User) if err := c.Bind(u); err != nil { return err } id, := strconv.Atoi(c.Param("id")) users[id].Name = u.Name return c.JSON(http.StatusOK, users[id]) }