Skip to content

Commit

Permalink
chore: use go 1.23 (evcc-io#14647)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Aug 15, 2024
1 parent 40b6d1b commit 0f511ce
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Default

env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy updated templates

env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23

on:
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Nightly Build

env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23

on:
schedule: # runs on the default branch: master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release

env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy data to website

env:
GO_VERSION: ^1.22
GO_VERSION: ^1.23

on:
release:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
go: "1.22"
go: "1.23"

issues:
exclude:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions cmd/configure/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
_ "embed"
"errors"
"fmt"
"maps"
"os"
"slices"
"strconv"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/evcc-io/evcc

go 1.22.0
go 1.23

require (
dario.cat/mergo v1.0.0
Expand Down
5 changes: 3 additions & 2 deletions meter/goodwe/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions server/db/settings/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down
6 changes: 1 addition & 5 deletions tariff/fixed/day.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
5 changes: 3 additions & 2 deletions util/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions util/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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%.]+))?}`)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions util/logstash/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions util/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package registry
import (
"context"
"fmt"

"golang.org/x/exp/maps"
"maps"
"slices"
)

type (
Expand Down Expand Up @@ -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] {
Expand Down

0 comments on commit 0f511ce

Please sign in to comment.