i want to call GetUsers from Insert function, but i don't know.
func GetUsers(c echo.Context) error{
result := models.GetUsers()
return c.Render(http.StatusOK, "users.html", result)
}
func Insert(c echo.Context) error{
models.Insert()
return c.GetUsers()
}
You can call it from Insert
simply using GetUsers
.
func Insert(c echo.Context) error{
models.Insert()
return GetUsers(c)
}
The syntax you used, c.GetUsers()
requires GetUsers
to be a method declared with Context
as its receiver type—in the echo
package—a like so:
// package echo
func (c Context) GetUsers() error {
…
}
// package other
func Insert(c echo.Context) error{
models.Insert()
return c.GetUsers()
}
But I am going to assume this is not what you want, since a Context
idiomatically should not contain users.