From f59f1293540381e2fcf01a8e666cbb23e31b4a09 Mon Sep 17 00:00:00 2001 From: dhax Date: Wed, 24 Jul 2024 23:44:32 +0200 Subject: [PATCH] silence go vet, staticcheck --- api/admin/accounts.go | 8 ++++---- api/app/account.go | 4 ++-- api/app/profile.go | 4 ++-- api/server.go | 2 +- email/email.go | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/api/admin/accounts.go b/api/admin/accounts.go index e11b954..0c048fa 100644 --- a/api/admin/accounts.go +++ b/api/admin/accounts.go @@ -122,9 +122,9 @@ func (rs *AccountResource) create(w http.ResponseWriter, r *http.Request) { } if err := rs.Store.Create(data.Account); err != nil { - switch err.(type) { + switch err := err.(type) { case validation.Errors: - render.Render(w, r, ErrValidation(ErrAccountValidation, err.(validation.Errors))) + render.Render(w, r, ErrValidation(ErrAccountValidation, err)) return } render.Render(w, r, ErrInvalidRequest(err)) @@ -147,9 +147,9 @@ func (rs *AccountResource) update(w http.ResponseWriter, r *http.Request) { } if err := rs.Store.Update(acc); err != nil { - switch err.(type) { + switch err := err.(type) { case validation.Errors: - render.Render(w, r, ErrValidation(ErrAccountValidation, err.(validation.Errors))) + render.Render(w, r, ErrValidation(ErrAccountValidation, err)) return } render.Render(w, r, ErrInvalidRequest(err)) diff --git a/api/app/account.go b/api/app/account.go index d0f1d70..3746b08 100644 --- a/api/app/account.go +++ b/api/app/account.go @@ -107,9 +107,9 @@ func (rs *AccountResource) update(w http.ResponseWriter, r *http.Request) { } if err := rs.Store.Update(acc); err != nil { - switch err.(type) { + switch err := err.(type) { case validation.Errors: - render.Render(w, r, ErrValidation(ErrAccountValidation, err.(validation.Errors))) + render.Render(w, r, ErrValidation(ErrAccountValidation, err)) return } render.Render(w, r, ErrRender(err)) diff --git a/api/app/profile.go b/api/app/profile.go index fef4681..9fb2105 100644 --- a/api/app/profile.go +++ b/api/app/profile.go @@ -89,9 +89,9 @@ func (rs *ProfileResource) update(w http.ResponseWriter, r *http.Request) { } if err := rs.Store.Update(p); err != nil { - switch err.(type) { + switch err := err.(type) { case validation.Errors: - render.Render(w, r, ErrValidation(ErrProfileValidation, err.(validation.Errors))) + render.Render(w, r, ErrValidation(ErrProfileValidation, err)) return } render.Render(w, r, ErrRender(err)) diff --git a/api/server.go b/api/server.go index 7b8965d..3c01762 100644 --- a/api/server.go +++ b/api/server.go @@ -52,7 +52,7 @@ func (srv *Server) Start() { }() log.Printf("Listening on %s\n", srv.Addr) - quit := make(chan os.Signal) + quit := make(chan os.Signal, 1) signal.Notify(quit, os.Interrupt) sig := <-quit log.Println("Shutting down server... Reason:", sig) diff --git a/email/email.go b/email/email.go index ea860c2..8e91636 100644 --- a/email/email.go +++ b/email/email.go @@ -48,7 +48,7 @@ func NewMailer() (*Mailer, error) { } s := &Mailer{ - client: mail.NewPlainDialer(smtp.Host, smtp.Port, smtp.User, smtp.Password), + client: mail.NewDialer(smtp.Host, smtp.Port, smtp.User, smtp.Password), from: NewEmail(viper.GetString("email_from_name"), viper.GetString("email_from_address")), } @@ -157,7 +157,7 @@ func formatAsDate(t time.Time) string { } func formatAsDuration(t time.Time) string { - dur := t.Sub(time.Now()) + dur := time.Until(t) hours := int(dur.Hours()) mins := int(dur.Minutes())