From 159bee1e9f43108a46d6465826987a0ec66363d2 Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Wed, 4 Feb 2026 10:23:23 +0100 Subject: [PATCH] Fix QF1011: could omit type ... from declaration; it will be inferred from the right-hand side (staticcheck) --- collectors/memstatMetric.go | 2 +- collectors/nvidiaMetric.go | 6 +++--- internal/metricAggregator/metricAggregatorFunctions.go | 2 +- internal/metricRouter/metricCache.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/collectors/memstatMetric.go b/collectors/memstatMetric.go index 572fb36..00919ad 100644 --- a/collectors/memstatMetric.go +++ b/collectors/memstatMetric.go @@ -174,7 +174,7 @@ func (m *MemstatCollector) Read(interval time.Duration, output chan lp.CCMessage sendStats := func(stats map[string]MemstatStats, tags map[string]string) { for match, name := range m.matches { var value float64 = 0 - var unit string = "" + unit := "" if v, ok := stats[match]; ok { value = v.value if len(v.unit) > 0 { diff --git a/collectors/nvidiaMetric.go b/collectors/nvidiaMetric.go index 65d46e7..e6b03d5 100644 --- a/collectors/nvidiaMetric.go +++ b/collectors/nvidiaMetric.go @@ -222,7 +222,7 @@ func readMemoryInfo(device *NvidiaCollectorDevice, output chan lp.CCMessage) err var total uint64 var used uint64 var reserved uint64 = 0 - var v2 bool = false + v2 := false meminfo, ret := nvml.DeviceGetMemoryInfo(device.device) if ret != nvml.SUCCESS { err := errors.New(nvml.ErrorString(ret)) @@ -768,7 +768,7 @@ func readRemappedRows(device *NvidiaCollectorDevice, output chan lp.CCMessage) e } } if !device.excludeMetrics["nv_remapped_rows_pending"] { - var p int = 0 + p := 0 if pending { p = 1 } @@ -778,7 +778,7 @@ func readRemappedRows(device *NvidiaCollectorDevice, output chan lp.CCMessage) e } } if !device.excludeMetrics["nv_remapped_rows_failure"] { - var f int = 0 + f := 0 if failure { f = 1 } diff --git a/internal/metricAggregator/metricAggregatorFunctions.go b/internal/metricAggregator/metricAggregatorFunctions.go index 58134c1..997a168 100644 --- a/internal/metricAggregator/metricAggregatorFunctions.go +++ b/internal/metricAggregator/metricAggregatorFunctions.go @@ -169,7 +169,7 @@ func medianfunc(args interface{}) (interface{}, error) { func lenfunc(args interface{}) (interface{}, error) { var err error = nil - var length int = 0 + length := 0 switch values := args.(type) { case []float64: length = len(values) diff --git a/internal/metricRouter/metricCache.go b/internal/metricRouter/metricCache.go index 03fcbfc..d7f1911 100644 --- a/internal/metricRouter/metricCache.go +++ b/internal/metricRouter/metricCache.go @@ -161,8 +161,8 @@ func (c *metricCache) DeleteAggregation(name string) error { // is the current one, index=1 the last interval and so on. Returns and empty array if a wrong index // is given (negative index, index larger than configured number of total intervals, ...) func (c *metricCache) GetPeriod(index int) (time.Time, time.Time, []lp.CCMessage) { - var start time.Time = time.Now() - var stop time.Time = time.Now() + start := time.Now() + stop := time.Now() var metrics []lp.CCMessage if index >= 0 && index < c.numPeriods { pindex := c.curPeriod - index