From 9671dfbdb5674e49a85280a634f7bc727d511cf6 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Tue, 28 Jan 2025 12:54:17 +0100 Subject: [PATCH] Bump Go Version in build and golangci --- .github/workflows/build.yml | 2 +- .github/workflows/golangci-lint.yml | 2 +- .golangci.yml | 1 + cmd/config.go | 4 ++-- cmd/health.go | 2 +- cmd/query.go | 9 +++++---- cmd/root.go | 2 +- internal/api/api.go | 4 ++-- internal/client/client.go | 3 ++- 9 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2457d4d..3e1d8b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21 + go-version: 1.23 - name: Test run: go test -v ./... diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 466bd34..eae1120 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -17,4 +17,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.54 + version: v1.61 diff --git a/.golangci.yml b/.golangci.yml index 4113c50..f84cbe5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,6 +22,7 @@ linters: - goerr113 - godox - gomnd + - mnd - nakedret - musttag - nlreturn diff --git a/cmd/config.go b/cmd/config.go index e20b196..8d905a6 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -2,7 +2,7 @@ package cmd import ( "context" - "fmt" + "errors" "net" "net/http" "net/url" @@ -72,7 +72,7 @@ func (c *Config) NewClient() *client.Client { if c.BasicAuth != "" { s := strings.Split(c.BasicAuth, ":") if len(s) != 2 { - check.ExitError(fmt.Errorf("specify the user name and password for server authentication ")) + check.ExitError(errors.New("specify the user name and password for server authentication ")) } var u = s[0] diff --git a/cmd/health.go b/cmd/health.go index c7429f5..00eeb2b 100644 --- a/cmd/health.go +++ b/cmd/health.go @@ -35,7 +35,7 @@ var healthCmd = &cobra.Command{ API translation: pass = OK fail = CRITICAL`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { // Creating an client and connecting to the API c := cliConfig.NewClient() diff --git a/cmd/query.go b/cmd/query.go index 202194f..42a2d51 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -1,6 +1,7 @@ package cmd import ( + "errors" "fmt" "net/http" "os" @@ -57,9 +58,9 @@ func convertToFloat64(value interface{}) (float64, error) { case uint: return float64(res), nil case string: - return 0, fmt.Errorf("string value can not be evaluated") + return 0, errors.New("string value can not be evaluated") default: - return 0, fmt.Errorf("unknown data type") + return 0, errors.New("unknown data type") } } @@ -152,12 +153,12 @@ var queryCmd = &cobra.Command{ Use: "query", Short: "Checks one specific or multiple values from the database using flux", Long: `Checks one specific or multiple values from the database using flux`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var fluxQuery string var err error if cliQueryConfig.FluxFile == "" && cliQueryConfig.FluxString == "" { - check.ExitError(fmt.Errorf("flux script needs to be defined with either --flux-file or --flux-string")) + check.ExitError(errors.New("flux script needs to be defined with either --flux-file or --flux-string")) } crit, err = check.ParseThreshold(cliQueryConfig.Critical) diff --git a/cmd/root.go b/cmd/root.go index 890d678..1bd5153 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ var Timeout = 30 var rootCmd = &cobra.Command{ Use: "check_influxdb", Short: "An Icinga check plugin to check InfluxDB", - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(_ *cobra.Command, _ []string) { go check.HandleTimeout(Timeout) }, Run: Usage, diff --git a/internal/api/api.go b/internal/api/api.go index 2b462a1..b309fe8 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -2,7 +2,7 @@ package influxdb import ( "encoding/json" - "fmt" + "errors" "strconv" "strings" ) @@ -32,7 +32,7 @@ func (v *APIVersion) UnmarshalJSON(b []byte) error { majorVersion, convErr := strconv.Atoi(version[0]) if convErr != nil { - return fmt.Errorf("could not determine version") + return errors.New("could not determine version") } v.MajorVersion = majorVersion diff --git a/internal/client/client.go b/internal/client/client.go index b65dc07..4396bc4 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -3,6 +3,7 @@ package client import ( "context" "encoding/json" + "errors" "fmt" "net/http" "net/url" @@ -47,7 +48,7 @@ func (c *Client) Version() (influxdb.APIVersion, error) { // Do the HTTP Request to the URL. resp, err := c.Client.Do(req) if resp == nil { - return v, fmt.Errorf("could not reach influxdb instance") + return v, errors.New("could not reach influxdb instance") } if err != nil {