chore: use go 1.23 (#14647)

This commit is contained in:
andig 2024-08-15 14:00:47 +02:00 • committed by GitHub
parent 40b6d1b7f3
commit 0f511ce93f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 27 additions and 31 deletions

View file

@ -1,7 +1,7 @@
name: Default
env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23
on:
push:

View file

@ -1,7 +1,7 @@
name: Deploy updated templates
env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23
on:
schedule:

View file

@ -1,7 +1,7 @@
name: Nightly Build
env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23
on:
schedule: # runs on the default branch: master

View file

@ -1,7 +1,7 @@
name: Release
env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23
on:
push:

View file

@ -1,7 +1,7 @@
name: Deploy data to website
env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23
on:
release:

View file

@ -1,5 +1,5 @@
run:
go: "1.22"
go: "1.23"
issues:
exclude:

View file

@ -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:

View file

@ -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.

View file

@ -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()

2
go.mod
View file

@ -1,6 +1,6 @@
module github.com/evcc-io/evcc
go 1.22.0
go 1.23
require (
dario.cat/mergo v1.0.0

View file

@ -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 {

View file

@ -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)
})

View file

@ -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")
}

View file

@ -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

View file

@ -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

View file

@ -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 {

View file

@ -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] {