The analyzer has detected a variable whose value was overwritten before it was used.
The example:
func createUser(req *http.Request) error {
user, err := parseUser(req)
if err != nil {
return err
}
err = validateUser(user)
err = saveUser(user)
return err
}
The return value of the validateUser function is assigned to the err variable. On the next line, a new value is assigned to the same variable. This means that the result of validateUser was not handled.
To fix this, add a check for the err variable immediately after assigning it the return value of validateUser:
func createUser(req *http.Request) error {
user, err := parseUser(req)
if err != nil {
return err
}
err = validateUser(user)
if err != nil {
return err
}
err = saveUser(user)
return err
}
This diagnostic rule is classified as:
Was this page helpful?