Commit 4d6386e9 by Karsten Weiss

Use fmt.Errorf() (gosimple)

This fixes:
pkg/cmd/grafana-cli/commands/install_command.go:36:11: should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (S1028)
pkg/models/org_user.go:53:11: should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (S1028)
pkg/services/notifications/mailer.go:138:16: should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (S1028)
parent 4d87cb03
...@@ -33,7 +33,7 @@ func validateInput(c CommandLine, pluginFolder string) error { ...@@ -33,7 +33,7 @@ func validateInput(c CommandLine, pluginFolder string) error {
fileInfo, err := os.Stat(pluginsDir) fileInfo, err := os.Stat(pluginsDir)
if err != nil { if err != nil {
if err = os.MkdirAll(pluginsDir, os.ModePerm); err != nil { if err = os.MkdirAll(pluginsDir, os.ModePerm); err != nil {
return errors.New(fmt.Sprintf("pluginsDir (%s) is not a writable directory", pluginsDir)) return fmt.Errorf("pluginsDir (%s) is not a writable directory", pluginsDir)
} }
return nil return nil
} }
......
...@@ -50,7 +50,7 @@ func (r *RoleType) UnmarshalJSON(data []byte) error { ...@@ -50,7 +50,7 @@ func (r *RoleType) UnmarshalJSON(data []byte) error {
if !(*r).IsValid() { if !(*r).IsValid() {
if (*r) != "" { if (*r) != "" {
return errors.New(fmt.Sprintf("JSON validation error: invalid role value: %s", *r)) return fmt.Errorf("JSON validation error: invalid role value: %s", *r)
} }
*r = ROLE_VIEWER *r = ROLE_VIEWER
......
...@@ -7,7 +7,6 @@ package notifications ...@@ -7,7 +7,6 @@ package notifications
import ( import (
"bytes" "bytes"
"crypto/tls" "crypto/tls"
"errors"
"fmt" "fmt"
"html/template" "html/template"
"net" "net"
...@@ -135,7 +134,7 @@ func buildEmailMessage(cmd *m.SendEmailCommand) (*Message, error) { ...@@ -135,7 +134,7 @@ func buildEmailMessage(cmd *m.SendEmailCommand) (*Message, error) {
subjectText, hasSubject := subjectData["value"] subjectText, hasSubject := subjectData["value"]
if !hasSubject { if !hasSubject {
return nil, errors.New(fmt.Sprintf("Missing subject in Template %s", cmd.Template)) return nil, fmt.Errorf("Missing subject in Template %s", cmd.Template)
} }
subjectTmpl, err := template.New("subject").Parse(subjectText.(string)) subjectTmpl, err := template.New("subject").Parse(subjectText.(string))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment