From fa78b2cbde1e6aff0ce425eddb5f2cf70e0978f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= Date: Mon, 20 Apr 2026 12:32:46 +0200 Subject: [PATCH] apply go fix --- config.go | 2 +- exit.go | 2 +- perfdata/type.go | 10 +++++----- result/worst_test.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config.go b/config.go index b10eeae..3e01d0a 100644 --- a/config.go +++ b/config.go @@ -105,7 +105,7 @@ func (c *Config) addDefaultFlags() { // type Config struct { // Token string `env:"BEARER_TOKEN"` // } -func LoadFromEnv(config interface{}) { +func LoadFromEnv(config any) { configValue := reflect.ValueOf(config).Elem() configType := configValue.Type() diff --git a/exit.go b/exit.go index 6f16d13..0273ad1 100644 --- a/exit.go +++ b/exit.go @@ -21,7 +21,7 @@ var PrintStack = true // Output is the formatting string, and the rest of the arguments help adding values. // // Also see fmt package: https://golang.org/pkg/fmt -func Exitf(rc int, output string, args ...interface{}) { +func Exitf(rc int, output string, args ...any) { ExitRaw(rc, fmt.Sprintf(output, args...)) } diff --git a/perfdata/type.go b/perfdata/type.go index 9a29ee6..b7179fe 100644 --- a/perfdata/type.go +++ b/perfdata/type.go @@ -19,7 +19,7 @@ var replacer = strings.NewReplacer("=", "_", "`", "_", "'", "_", "\"", "_") // represent a valid measurement, e.g INF for floats // This error can probably ignored in most cases and the perfdata point omitted, // but silently dropping the value and returning the empty strings seems like bad style -func formatNumeric(value interface{}) (string, error) { +func formatNumeric(value any) (string, error) { switch v := value.(type) { case float64: if math.IsInf(v, 0) { @@ -61,13 +61,13 @@ func formatNumeric(value interface{}) (string, error) { // https://icinga.com/docs/icinga-2/latest/doc/05-service-monitoring/#unit-of-measurement-uom type Perfdata struct { Label string - Value interface{} + Value any // Uom is the unit-of-measurement, see links above for details. Uom string Warn *check.Threshold Crit *check.Threshold - Min interface{} - Max interface{} + Min any + Max any } // String returns the proper format for the plugin output @@ -109,7 +109,7 @@ func (p Perfdata) ValidatedString() (string, error) { } // Limits - for _, value := range []interface{}{p.Min, p.Max} { + for _, value := range []any{p.Min, p.Max} { sb.WriteString(";") if value != nil { diff --git a/result/worst_test.go b/result/worst_test.go index c4e509b..64580ec 100644 --- a/result/worst_test.go +++ b/result/worst_test.go @@ -44,7 +44,7 @@ func BenchmarkWorstState(b *testing.B) { // Initialize slice for benchmarking states := make([]int, 0, 100) - for i := 0; i < 100; i++ { + for i := range 100 { states = append(states, i%4) }