diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 84cf9f9b2..4d2d1ef68 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -1,7 +1,7 @@ name: Default env: - GO_VERSION: ^1.22 + GO_VERSION: ^1.23 on: push: diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index d92966550..033fa6979 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,7 +1,7 @@ name: Deploy updated templates env: - GO_VERSION: ^1.22 + GO_VERSION: ^1.23 on: schedule: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 91a33a558..7ee5ecb6d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,7 +1,7 @@ name: Nightly Build env: - GO_VERSION: ^1.22 + GO_VERSION: ^1.23 on: schedule: # runs on the default branch: master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 27cfb478d..c992aa03e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ name: Release env: - GO_VERSION: ^1.22 + GO_VERSION: ^1.23 on: push: diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 07536caa3..22350181b 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -1,7 +1,7 @@ name: Deploy data to website env: - GO_VERSION: ^1.22 + GO_VERSION: ^1.23 on: release: diff --git a/.golangci.yml b/.golangci.yml index ee6d9976f..aadc6c84a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - go: "1.22" + go: "1.23" issues: exclude: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 706a19f61..37dff52f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ #### Development environment -Developing evcc requires [Go][1] 1.22 and [Node][2] 18. We recommend VSCode with the [Go](https://marketplace.visualstudio.com/items?itemName=golang.Go), [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) and [Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur) extensions. +Developing evcc requires [Go][1] 1.23 and [Node][2] 18. We recommend VSCode with the [Go](https://marketplace.visualstudio.com/items?itemName=golang.Go), [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) and [Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur) extensions. We use linters (golangci-lint, Prettier) to keep a coherent source code formatting. It's recommended to use the format-on-save feature of your editor. You can manually reformat your code by running: diff --git a/Dockerfile b/Dockerfile index 1bc6303a2..32f1626c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN make ui # STEP 2 build executable binary -FROM --platform=$BUILDPLATFORM golang:1.22-alpine as builder +FROM --platform=$BUILDPLATFORM golang:1.23-alpine as builder # Install git + SSL ca certificates. # Git is required for fetching the dependencies. diff --git a/cmd/configure/main.go b/cmd/configure/main.go index 041142df6..c6f19ad8a 100644 --- a/cmd/configure/main.go +++ b/cmd/configure/main.go @@ -5,6 +5,7 @@ import ( _ "embed" "errors" "fmt" + "maps" "os" "slices" "strconv" @@ -18,7 +19,6 @@ import ( "github.com/evcc-io/evcc/util/machine" "github.com/evcc-io/evcc/util/templates" "github.com/nicksnyder/go-i18n/v2/i18n" - "golang.org/x/exp/maps" "golang.org/x/text/language" ) @@ -107,7 +107,7 @@ func (c *CmdConfigure) Run(log *util.Logger, flagLang string, advancedMode, expa } } - log.FATAL.Fatalln("invalid category:", category, "have:", maps.Keys(DeviceCategories)) + log.FATAL.Fatalln("invalid category:", category, "have:", slices.Collect(maps.Keys(DeviceCategories))) } fmt.Println() diff --git a/go.mod b/go.mod index 6968b318b..9324c60b7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/evcc-io/evcc -go 1.22.0 +go 1.23 require ( dario.cat/mergo v1.0.0 diff --git a/meter/goodwe/server.go b/meter/goodwe/server.go index d2f1d1665..681d3b45a 100644 --- a/meter/goodwe/server.go +++ b/meter/goodwe/server.go @@ -2,13 +2,14 @@ package goodwe import ( "encoding/binary" + "maps" "net" + "slices" "sync" "time" "github.com/cenkalti/backoff/v4" "github.com/evcc-io/evcc/util" - "golang.org/x/exp/maps" ) var ( @@ -66,7 +67,7 @@ func (m *Server) readData() { for { mu.RLock() - ips := maps.Keys(m.inverters) + ips := slices.Collect(maps.Keys(m.inverters)) mu.RUnlock() for _, ip := range ips { diff --git a/server/db/settings/setting.go b/server/db/settings/setting.go index 2cf8d6851..429469ab0 100644 --- a/server/db/settings/setting.go +++ b/server/db/settings/setting.go @@ -55,8 +55,7 @@ func All() []setting { mu.RLock() defer mu.RUnlock() - res := slices.Clone(settings) - slices.SortFunc(res, func(i, j setting) int { + res := slices.SortedFunc(slices.Values(settings), func(i, j setting) int { return cmp.Compare(i.Key, j.Key) }) diff --git a/tariff/fixed/day.go b/tariff/fixed/day.go index f09e93368..3007f1ffc 100644 --- a/tariff/fixed/day.go +++ b/tariff/fixed/day.go @@ -110,11 +110,7 @@ func ParseDays(s string) ([]Day, error) { return nil, errors.New("too many days") } - sorted := make([]Day, len(res)) - copy(sorted, res) - slices.Sort(sorted) - - if len(slices.Compact(sorted)) < len(res) { + if len(slices.Compact(slices.Sorted(slices.Values(res)))) < len(res) { return nil, errors.New("duplicate days") } diff --git a/util/cache.go b/util/cache.go index a2746dc32..77796ba57 100644 --- a/util/cache.go +++ b/util/cache.go @@ -2,10 +2,11 @@ package util import ( "fmt" + "maps" + "slices" "sync" "github.com/evcc-io/evcc/util/encode" - "golang.org/x/exp/maps" ) // Cache is a data store @@ -89,7 +90,7 @@ func (c *Cache) All() []Param { c.mu.RLock() defer c.mu.RUnlock() - return maps.Values(c.val) + return slices.Collect(maps.Values(c.val)) } // Add entry to cache diff --git a/util/format.go b/util/format.go index 01e196295..e54e50899 100644 --- a/util/format.go +++ b/util/format.go @@ -4,13 +4,14 @@ import ( "bytes" "fmt" "html/template" + "maps" "regexp" + "slices" "strings" "time" "github.com/go-sprout/sprout" "github.com/samber/lo" - "golang.org/x/exp/maps" ) var re = regexp.MustCompile(`(?i)\${(\w+)(:([a-zA-Z0-9%.]+))?}`) @@ -96,7 +97,7 @@ func ReplaceFormatted(s string, kv map[string]interface{}) (string, error) { // return missing keys if len(wanted) > 0 { - return "", fmt.Errorf("wanted: %v, got: %v", wanted, maps.Keys(kv)) + return "", fmt.Errorf("wanted: %v, got: %v", slices.Sorted(slices.Values(wanted)), slices.Sorted(maps.Keys(kv))) } return s, nil diff --git a/util/logstash/log.go b/util/logstash/log.go index ed555b099..15450932c 100644 --- a/util/logstash/log.go +++ b/util/logstash/log.go @@ -3,12 +3,12 @@ package logstash import ( "container/ring" "io" + "maps" "slices" "strings" "sync" jww "github.com/spf13/jwalterweatherman" - "golang.org/x/exp/maps" ) var DefaultHandler = New(10000) @@ -91,9 +91,7 @@ func (l *logger) Areas() []string { } } - keys := maps.Keys(areas) - slices.Sort(keys) - return keys + return slices.Sorted(maps.Keys(areas)) } func (l *logger) All(areas []string, level jww.Threshold, count int) []string { diff --git a/util/registry/registry.go b/util/registry/registry.go index 3394f1b35..7ad9c80fb 100644 --- a/util/registry/registry.go +++ b/util/registry/registry.go @@ -3,8 +3,8 @@ package registry import ( "context" "fmt" - - "golang.org/x/exp/maps" + "maps" + "slices" ) type ( @@ -38,7 +38,7 @@ func (r registry[T]) Get(name string) (factoryFunc[T], error) { } func (r registry[T]) Types() []string { - return maps.Keys(r.data) + return slices.Collect(maps.Keys(r.data)) } func New[T any](typ string) registry[T] {