diff --git a/pkg/api/http_server.go b/pkg/api/http_server.go index d2094b33cb1..926a687c791 100644 --- a/pkg/api/http_server.go +++ b/pkg/api/http_server.go @@ -258,7 +258,7 @@ func (hs *HTTPServer) metricsEndpoint(ctx *macaron.Context) { return } - if ctx.Req.Method != "GET" || ctx.Req.URL.Path != "/metrics" { + if ctx.Req.Method != http.MethodGet || ctx.Req.URL.Path != "/metrics" { return } diff --git a/pkg/api/playlist.go b/pkg/api/playlist.go index bb429847dc0..bfc9f1b978c 100644 --- a/pkg/api/playlist.go +++ b/pkg/api/playlist.go @@ -1,6 +1,8 @@ package api import ( + "net/http" + "github.com/grafana/grafana/pkg/bus" _ "github.com/grafana/grafana/pkg/infra/log" m "github.com/grafana/grafana/pkg/models" @@ -33,7 +35,7 @@ func ValidateOrgPlaylist(c *m.ReqContext) { return } - if len(items) == 0 && c.Context.Req.Method != "DELETE" { + if len(items) == 0 && c.Context.Req.Method != http.MethodDelete { c.JsonApiErr(404, "Playlist is empty", itemsErr) return } diff --git a/pkg/setting/setting_test.go b/pkg/setting/setting_test.go index ae66b37bca3..f59e4d6e8aa 100644 --- a/pkg/setting/setting_test.go +++ b/pkg/setting/setting_test.go @@ -1,16 +1,21 @@ package setting import ( - "gopkg.in/ini.v1" "os" "path" "path/filepath" "runtime" "testing" + "gopkg.in/ini.v1" + . "github.com/smartystreets/goconvey/convey" ) +const ( + windows = "windows" +) + func TestLoadingSettings(t *testing.T) { Convey("Testing loading settings from ini file", t, func() { @@ -72,7 +77,7 @@ func TestLoadingSettings(t *testing.T) { }) Convey("Should be able to override via command line", func() { - if runtime.GOOS == "windows" { + if runtime.GOOS == windows { cfg := NewCfg() cfg.Load(&CommandLineArgs{ HomePath: "../../", @@ -106,7 +111,7 @@ func TestLoadingSettings(t *testing.T) { }) Convey("Defaults can be overridden in specified config file", func() { - if runtime.GOOS == "windows" { + if runtime.GOOS == windows { cfg := NewCfg() cfg.Load(&CommandLineArgs{ HomePath: "../../", @@ -128,7 +133,7 @@ func TestLoadingSettings(t *testing.T) { }) Convey("Command line overrides specified config file", func() { - if runtime.GOOS == "windows" { + if runtime.GOOS == windows { cfg := NewCfg() cfg.Load(&CommandLineArgs{ HomePath: "../../", @@ -150,7 +155,7 @@ func TestLoadingSettings(t *testing.T) { }) Convey("Can use environment variables in config values", func() { - if runtime.GOOS == "windows" { + if runtime.GOOS == windows { os.Setenv("GF_DATA_PATH", `c:\tmp\env_override`) cfg := NewCfg() cfg.Load(&CommandLineArgs{