Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error On CRUD Cookbook #135

Open
jung-jin-lee opened this issue Feb 13, 2020 · 0 comments
Open

Error On CRUD Cookbook #135

jung-jin-lee opened this issue Feb 13, 2020 · 0 comments

Comments

@jung-jin-lee
Copy link

jung-jin-lee commented Feb 13, 2020

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?

[AS-IS]
var (
users = map[int]*user{}
seq = 1
)
[TO-BE]
var (
users = map[int]*User{}
seq = 1
)

[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])
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant