diff --git a/backend/app/main.go b/backend/app/main.go index ecdb3dbee7..87bdff7be6 100644 --- a/backend/app/main.go +++ b/backend/app/main.go @@ -1,6 +1,7 @@ package main import ( + "errors" "fmt" "os" "os/signal" @@ -55,7 +56,8 @@ func main() { } if _, err := p.Parse(); err != nil { - if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp { + var flagsErr *flags.Error + if errors.As(err, &flagsErr) && flagsErr.Type == flags.ErrHelp { os.Exit(0) } os.Exit(1) diff --git a/backend/app/rest/api/rest_private.go b/backend/app/rest/api/rest_private.go index 0a7994e710..1b97440642 100644 --- a/backend/app/rest/api/rest_private.go +++ b/backend/app/rest/api/rest_private.go @@ -6,6 +6,7 @@ import ( "crypto/rand" "crypto/sha1" //nolint:gosec //not used for security "encoding/json" + "errors" "fmt" "html/template" "io" @@ -150,7 +151,7 @@ func (s *private) createCommentCtrl(w http.ResponseWriter, r *http.Request) { } id, err := s.dataService.Create(comment) - if err == service.ErrRestrictedWordsFound { + if errors.Is(err, service.ErrRestrictedWordsFound) { rest.SendErrorJSON(w, r, http.StatusBadRequest, err, "invalid comment", rest.ErrCommentRestrictWords) return } @@ -219,7 +220,7 @@ func (s *private) updateCommentCtrl(w http.ResponseWriter, r *http.Request) { } res, err := s.dataService.EditComment(locator, id, editReq) - if err == service.ErrRestrictedWordsFound { + if errors.Is(err, service.ErrRestrictedWordsFound) { rest.SendErrorJSON(w, r, http.StatusBadRequest, err, "invalid comment", rest.ErrCommentValidation) return }