From 8d7135076843b2f35a268e95e3e2c8ae78ab07ec Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 28 Dec 2025 11:06:45 +0100 Subject: [PATCH] chore: upgrade tools (#26220) --- .golangci.yml | 3 +++ Makefile | 4 ++-- api/store/types.go | 10 ---------- go.mod | 2 ++ go.sum | 2 ++ plugin/http.go | 2 +- vehicle/subaru.go | 2 +- vehicle/subaru/identity.go | 9 +++------ vehicle/subaru/types.go | 4 ++-- 9 files changed, 16 insertions(+), 22 deletions(-) delete mode 100644 api/store/types.go diff --git a/.golangci.yml b/.golangci.yml index 3db79fcc9..d0a732c22 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,6 +21,9 @@ linters: - wastedassign - whitespace settings: + modernize: + disable: + - stringsbuilder staticcheck: checks: - -SA1019 diff --git a/Makefile b/Makefile index 98aa3b70c..20159a686 100644 --- a/Makefile +++ b/Makefile @@ -53,10 +53,10 @@ docs:: lint:: golangci-lint run - go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.20.0 -test -category "-omitzero" -c 0 ./... + go tool modernize -test -c 0 -stringsbuilder=false -omitzero=false ./... modernize: - go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.20.0 -test -category "-omitzero" -fix ./... + go tool modernize -test -fix -stringsbuilder=false -omitzero=false ./... lint-ui:: npm run lint diff --git a/api/store/types.go b/api/store/types.go deleted file mode 100644 index 33b652a64..000000000 --- a/api/store/types.go +++ /dev/null @@ -1,10 +0,0 @@ -package store - -// Provider creates a Persister for given string key -type Provider func(string) Store - -// Store can load and store data -type Store interface { - Load(any) error - Save(any) error -} diff --git a/go.mod b/go.mod index 3570f424e..c64e3dadc 100644 --- a/go.mod +++ b/go.mod @@ -243,6 +243,7 @@ require ( golang.org/x/mod v0.31.0 // indirect golang.org/x/sys v0.39.0 // indirect golang.org/x/term v0.38.0 // indirect + golang.org/x/tools/gopls v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20251103181224-f26f9409b101 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 // indirect gopkg.in/sourcemap.v1 v1.0.5 // indirect @@ -260,6 +261,7 @@ tool ( github.com/evcc-io/openapi-mcp/cmd/openapi-mcp github.com/gokrazy/tools/cmd/gok go.uber.org/mock/mockgen + golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize ) replace github.com/grid-x/modbus => github.com/evcc-io/modbus v0.0.0-20250501165638-8b6f1fbdb7ea diff --git a/go.sum b/go.sum index 3575d4ff5..1c96f33f4 100644 --- a/go.sum +++ b/go.sum @@ -995,6 +995,8 @@ golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/tools/gopls v0.21.0 h1:k8RlBm3ES+GVe+fbTSkzwKgarmNwN+6aDalb0T0xfag= +golang.org/x/tools/gopls v0.21.0/go.mod h1:x/34IonzHuKpDDlMUjYezcjbwNOJ32FtrYOLqAuOmNo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/plugin/http.go b/plugin/http.go index f7eb4b848..73904d198 100644 --- a/plugin/http.go +++ b/plugin/http.go @@ -147,7 +147,7 @@ func dropNoCache(resp *http.Response, header string) { if h := resp.Header.Get(header); h != "" { var hh []string - for _, h := range strings.Split(h, ",") { + for h := range strings.SplitSeq(h, ",") { if s := strings.TrimSpace(h); strings.ToLower(s) != "no-cache" { hh = append(hh, s) } diff --git a/vehicle/subaru.go b/vehicle/subaru.go index 46ec4ae34..fe6a6dec1 100644 --- a/vehicle/subaru.go +++ b/vehicle/subaru.go @@ -20,7 +20,7 @@ func init() { } // NewSubaruFromConfig creates a new vehicle -func NewSubaruFromConfig(other map[string]interface{}) (api.Vehicle, error) { +func NewSubaruFromConfig(other map[string]any) (api.Vehicle, error) { cc := struct { embed `mapstructure:",squash"` User, Password, VIN string diff --git a/vehicle/subaru/identity.go b/vehicle/subaru/identity.go index e772e0f28..6f0c1e947 100644 --- a/vehicle/subaru/identity.go +++ b/vehicle/subaru/identity.go @@ -2,6 +2,7 @@ package subaru import ( "fmt" + "maps" "net/http" "net/url" "strings" @@ -113,9 +114,7 @@ func (v *Identity) fetchTokenCredentials(code string) error { } headers := make(map[string]string) - for k, v := range request.URLEncoding { - headers[k] = v - } + maps.Copy(headers, request.URLEncoding) headers["Authorization"] = AppAuthorization req, err := request.New(http.MethodPost, uri, strings.NewReader(data.Encode()), headers) if err != nil { @@ -163,9 +162,7 @@ func (v *Identity) refreshToken(token *oauth2.Token) (*oauth2.Token, error) { } headers := make(map[string]string) - for k, v := range request.URLEncoding { - headers[k] = v - } + maps.Copy(headers, request.URLEncoding) headers["Authorization"] = AppAuthorization var res oauth2.Token req, err := request.New(http.MethodPost, uri, strings.NewReader(data.Encode()), headers) diff --git a/vehicle/subaru/types.go b/vehicle/subaru/types.go index 5601bd0bc..187dfa0b9 100644 --- a/vehicle/subaru/types.go +++ b/vehicle/subaru/types.go @@ -40,8 +40,8 @@ type AuthCallback struct { } type AuthCallbackValue struct { - Name string `json:"name"` - Value interface{} `json:"value"` + Name string `json:"name"` + Value any `json:"value"` } type Token struct {