From 19c4119ff2afed574b81b9cf2b5efbaa307c9663 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Wed, 12 Feb 2025 18:01:44 +0100 Subject: [PATCH] change minimum golang requirement to 1.23 --- .golangci.yml | 2 +- Changes | 1 + Makefile | 4 ++-- buildtools/go.mod | 2 +- go.mod | 6 +++--- go.sum | 8 ++++---- pkg/snclient/snclient.go | 4 ++-- pkg/snclient/test_utils_test.go | 3 +-- pkg/utils/utils.go | 5 +++-- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 71849de6..6d65ca24 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -51,7 +51,7 @@ linters: - testpackage - wsl # deprecated - - exportloopref + - tenv issues: max-same-issues: 0 max-issues-per-linter: 0 diff --git a/Changes b/Changes index ba7b312c..c674023b 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ next: - fix check_files thresholds on total_size - update windows exporter to 0.30.2 - chore: update dependencies + - change minimum golang requirement to 1.23 0.30 Wed Jan 15 12:08:28 CET 2025 - fix check_drivesize letter: excludes diff --git a/Makefile b/Makefile index 02ccd797..8bdc0aaf 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,8 @@ GOVERSION:=$(shell \ ) # also update docs/install/build.md and .github/workflows/builds.yml when changing minimum version # find . -name go.mod (run make gomods afterwards) -MINGOVERSION:=00010022 -MINGOVERSIONSTR:=1.22 +MINGOVERSION:=00010023 +MINGOVERSIONSTR:=1.23 BUILD:=$(shell git rev-parse --short HEAD) REVISION:=$(shell ./buildtools/get_version | awk -F . '{ print $$3 }') # see https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md diff --git a/buildtools/go.mod b/buildtools/go.mod index ff922c77..bbe5c3b9 100644 --- a/buildtools/go.mod +++ b/buildtools/go.mod @@ -1,6 +1,6 @@ module tools -go 1.22.0 +go 1.23.0 require ( github.com/daixiang0/gci v0.12.3 diff --git a/go.mod b/go.mod index 0d5d0e32..5136822e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/consol-monitoring/snclient -go 1.22.0 +go 1.23.6 require ( github.com/beevik/ntp v1.4.3 @@ -14,7 +14,7 @@ require ( github.com/miekg/dns v1.1.63 github.com/otiai10/copy v1.14.1 github.com/prometheus/client_golang v1.20.5 - github.com/reeflective/readline v1.0.15 + github.com/reeflective/readline v1.1.2 github.com/sasha-s/go-deadlock v0.3.5 github.com/sassoftware/go-rpmutils v0.4.0 github.com/sevlyar/go-daemon v0.1.6 @@ -49,7 +49,7 @@ require ( github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/otiai10/mint v1.6.3 // indirect - github.com/petermattis/goid v0.0.0-20250121172306-05bcfb9a85dc // indirect + github.com/petermattis/goid v0.0.0-20250211185408-f2b9d978cd7a // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/prometheus/client_model v0.6.1 // indirect diff --git a/go.sum b/go.sum index 18d5b091..381122eb 100644 --- a/go.sum +++ b/go.sum @@ -61,8 +61,8 @@ github.com/otiai10/copy v1.14.1/go.mod h1:oQwrEDDOci3IM8dJF0d8+jnbfPDllW6vUjNc3D github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs= github.com/otiai10/mint v1.6.3/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= -github.com/petermattis/goid v0.0.0-20250121172306-05bcfb9a85dc h1:Xz/LkK9AJRY5QTkA1uE1faB8yeqRFjeKgwDtI13ogcY= -github.com/petermattis/goid v0.0.0-20250121172306-05bcfb9a85dc/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20250211185408-f2b9d978cd7a h1:ckxP/kGzsxvxXo8jO6E/0QJ8MMmwI7IRj4Fys9QbAZA= +github.com/petermattis/goid v0.0.0-20250211185408-f2b9d978cd7a/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= @@ -75,8 +75,8 @@ github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/reeflective/readline v1.0.15 h1:uB/M1sAc2yZGO14Ujgr/imLwQXqGdOhDDWAEHF+MBaE= -github.com/reeflective/readline v1.0.15/go.mod h1:3iOe/qyb2jEy0KqLrNlb/CojBVqxga9ACqz/VU22H6A= +github.com/reeflective/readline v1.1.2 h1:XhnNwVg7gQhrxk2cJ3/taU7KKPXEc9bCzl5oHrSi7aI= +github.com/reeflective/readline v1.1.2/go.mod h1:CwNkh9BmFBBCSO6mdDaNWb34rOqQsI9eYbxyqvOEazY= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= diff --git a/pkg/snclient/snclient.go b/pkg/snclient/snclient.go index dcbb0f3d..aad31e38 100644 --- a/pkg/snclient/snclient.go +++ b/pkg/snclient/snclient.go @@ -8,6 +8,7 @@ import ( "fmt" "io" "io/fs" + "maps" "net/http" _ "net/http/pprof" //nolint:gosec // default muxer is not exposed by default "os" @@ -31,7 +32,6 @@ import ( deadlock "github.com/sasha-s/go-deadlock" daemon "github.com/sevlyar/go-daemon" "github.com/shirou/gopsutil/v4/host" - "golang.org/x/exp/maps" ) const ( @@ -893,7 +893,7 @@ func (snc *Agent) restartWatcherCb(restartCb func()) { lastStat := map[string]*fs.FileInfo{} files := []string{} files = append(files, snc.runSet.files...) - files = append(files, maps.Keys(snc.config.alreadyIncluded)...) + files = slices.AppendSeq(files, maps.Keys(snc.config.alreadyIncluded)) files = append(files, binFile) ticker := time.NewTicker(500 * time.Millisecond) defer ticker.Stop() diff --git a/pkg/snclient/test_utils_test.go b/pkg/snclient/test_utils_test.go index 0228d9b4..ab8d5bc7 100644 --- a/pkg/snclient/test_utils_test.go +++ b/pkg/snclient/test_utils_test.go @@ -90,8 +90,7 @@ func MockSystemUtilities(t *testing.T, utils map[string]string) (tmpPath string) newTmp := t.TempDir() newPath := append([]string{newTmp}, pathElements...) - err := os.Setenv("PATH", strings.Join(newPath, ":")) - require.NoErrorf(t, err, "set env worked") + t.Setenv("PATH", strings.Join(newPath, ":")) tmpPath = newTmp } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7cbebbbb..ddd47d67 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -7,12 +7,14 @@ import ( "encoding/hex" "fmt" "io" + "maps" "math" "net/http" "os" "path/filepath" "regexp" "runtime" + "slices" "sort" "strconv" "strings" @@ -21,7 +23,6 @@ import ( "github.com/consol-monitoring/snclient/pkg/convert" "github.com/kdar/factorlog" - "golang.org/x/exp/maps" ) var reMountPassword = regexp.MustCompile(`//.*:.*@`) @@ -522,7 +523,7 @@ func SortRanked(list []string, ranks map[string]int) []string { // returns string map keys in sorted order func SortedKeys[V interface{}](m map[string]V) []string { - keys := maps.Keys(m) + keys := slices.AppendSeq(make([]string, 0, len(m)), maps.Keys(m)) sort.Strings(keys) return keys