my errors.go file
package errors
import (
"net/http"
)
type RestError struct {
Message string `json:"message"`
Status int `json:"status"`
Error string `json:"error"`
}
func (err *RestError) NewBadRequestError(message string) {
err.Message = message
err.Status = http.StatusBadRequest
err.Error = "bad_request"
}
my user.go file
package users
import (
errors "Utils/Errors"
)
type (
User struct {
ID uint `json:"id"`
Name string `json:"name"`
LastName string `json:"last_name"`
Email string `json:"email"`
}
)
func (u *User) Validate() (err *errors.RestError) {
if u.Name == "" {
return &err.NewBadRequestError("The name field can't be empty")
}
return nil
}
i always get the following compiler error
err.NewBadRequestError(*message) (no value) used as valuecompiler
Would like to know what i'm doing wrong. I also tried return &err.NewBadRequestError(message: "The name field can't be empty") but still get the following syntax error : missing ',' in argument listsyntax