chore(deps): update dependency golangci/golangci-lint to v2.6.0 (#2246)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
renovate[bot]
2025-11-02 19:41:27 +01:00
committed by GitHub
parent a523ef69fd
commit 3d0587d28c
14 changed files with 31 additions and 42 deletions

View File

@@ -775,6 +775,7 @@ func (c *Collector) workerBitlocker(ctx context.Context, initErrCh chan<- error)
// Otherwise, attempting to initialize and run parallel queries across
// goroutines will result in protected memory errors.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {

View File

@@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"log/slog"
"maps"
"reflect"
"regexp"
"slices"
@@ -184,7 +185,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
return reflect.StructField{
Name: strings.ToUpper(sanitizeMetricName(name)),
Type: reflect.TypeOf(float64(0)),
Type: reflect.TypeFor[float64](),
Tag: reflect.StructTag(fmt.Sprintf(`perfdata:"%s"`, name)),
}, nil
}(counter.Name)
@@ -200,13 +201,13 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
if object.Instances != nil {
fields = append(fields, reflect.StructField{
Name: "Name",
Type: reflect.TypeOf(""),
Type: reflect.TypeFor[string](),
})
}
fields = append(fields, reflect.StructField{
Name: "MetricType",
Type: reflect.TypeOf(prometheus.ValueType(0)),
Type: reflect.TypeFor[prometheus.ValueType](),
})
valueType := reflect.StructOf(fields)
@@ -321,7 +322,7 @@ func (c *Collector) collectObject(ch chan<- prometheus.Metric, perfDataObject Ob
continue
}
if field.Kind() != reflect.TypeOf(prometheus.ValueType(0)).Kind() {
if field.Kind() != reflect.TypeFor[prometheus.ValueType]().Kind() {
errs = append(errs, fmt.Errorf("failed to cast MetricType for %s to prometheus.ValueType", counter.Name))
continue
@@ -351,9 +352,7 @@ func (c *Collector) collectObject(ch chan<- prometheus.Metric, perfDataObject Ob
}
}
for key, value := range counter.Labels {
labels[key] = value
}
maps.Copy(labels, counter.Labels)
switch counter.Type {
case "counter":

View File

@@ -248,6 +248,7 @@ func getScheduledTasks() (ScheduledTasks, error) {
// Otherwise, attempting to initialize and run parallel queries across
// goroutines will result in protected memory errors.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
@@ -256,6 +257,7 @@ func getScheduledTasks() (ScheduledTasks, error) {
return nil, err
}
}
defer ole.CoUninitialize()
schedClassID, err := ole.ClassIDFrom(SCHEDULED_TASK_PROGRAM_ID)

View File

@@ -25,6 +25,7 @@ import (
"os"
"path/filepath"
"reflect"
"slices"
"sort"
"strings"
"time"
@@ -183,17 +184,7 @@ func (c *Collector) convertMetricFamily(logger *slog.Logger, metricFamily *dto.M
}
for k := range allLabelNames {
present := false
for _, name := range names {
if k == name {
present = true
break
}
}
if !present {
if !slices.Contains(names, k) {
names = append(names, k)
values = append(values, "")
}

View File

@@ -64,6 +64,7 @@ func TestMultipleDirectories(t *testing.T) {
err := val.Write(&metric)
require.NoError(t, err)
//nolint:modernize,perfsprint
got += metric.String()
}
@@ -102,6 +103,7 @@ func TestDuplicateFileName(t *testing.T) {
err := val.Write(&metric)
require.NoError(t, err)
//nolint:perfsprint
got += metric.String()
}

View File

@@ -176,6 +176,7 @@ func (c *Collector) scheduleUpdateStatus(ctx context.Context, logger *slog.Logge
// Otherwise, attempting to initialize and run parallel queries across
// goroutines will result in protected memory errors.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {