Skip to content

Error On CRUD Cookbook #135

Open
Open
@jung-jin-lee

Description

@jung-jin-lee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions