Skip to content

Commit

Permalink
Require Go 1.21 (evcc-io#9244)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Aug 17, 2023
1 parent 0854849 commit e14fdf6
Show file tree
Hide file tree
Showing 55 changed files with 116 additions and 127 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Default

env:
GO_VERSION: ^1.21

on:
push:
branches:
Expand All @@ -18,7 +21,7 @@ jobs:
# - uses: actions/setup-go@v4
- uses: erezrokah/setup-go@feat/add_cache_prefix
with:
go-version: ^1.20
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: clean-cache-
id: go

Expand Down Expand Up @@ -46,7 +49,7 @@ jobs:

- uses: erezrokah/setup-go@feat/add_cache_prefix
with:
go-version: ^1.20
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: build-cache-
id: go

Expand All @@ -70,7 +73,7 @@ jobs:
# - uses: actions/setup-go@v4
- uses: erezrokah/setup-go@feat/add_cache_prefix
with:
go-version: ^1.20
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: test-cache-
id: go

Expand All @@ -86,7 +89,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: ^1.20
go-version: ${{ env.GO_VERSION }}
cache: false # avoid cache thrashing
id: go

Expand Down Expand Up @@ -142,7 +145,7 @@ jobs:

- uses: erezrokah/setup-go@feat/add_cache_prefix
with:
go-version: ^1.20
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: integration-cache-
id: go

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Deploy updated templates

env:
GO_VERSION: ^1.21

on:
push:
branches: [master]
Expand All @@ -16,7 +19,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: ^1.20
go-version: ${{ env.GO_VERSION }}
id: go

- name: Build docs
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Nightly Build

env:
GO_VERSION: ^1.21

on:
schedule: # runs on the default branch: master
- cron: "0 2 * * *" # run at 2 AM UTC
Expand Down Expand Up @@ -81,7 +84,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: ^1.20
go-version: ${{ env.GO_VERSION }}
id: go

- name: Install Cloudsmith CLI
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: Release

env:
GO_VERSION: ^1.21

on:
push:
tags:
- "*"

jobs:
call-build-workflow:
if: "startsWith(github.ref, 'refs/tags')"
if: startsWith(github.ref, 'refs/tags')
uses: evcc-io/evcc/.github/workflows/default.yml@master

docker:
Expand Down Expand Up @@ -60,7 +63,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ^1.20
go-version: ${{ env.GO_VERSION }}
id: go

- name: Install Cloudsmith CLI
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Deploy data to website

env:
GO_VERSION: ^1.21

on:
push:
branches: [master]
Expand All @@ -16,7 +19,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: ^1.20
go-version: ${{ env.GO_VERSION }}
id: go

- name: Build docs
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.20
go: "1.21"
issues:
exclude:
- .regActualCurrent. is unused
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.20-alpine as builder
FROM --platform=$BUILDPLATFORM golang:1.21-alpine as builder

# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ clean::
rm -rf dist/

install::
go install $$(go list -f '{{join .Imports " "}}' tools.go)
go install $$(go list -e -f '{{join .Imports " "}}' tools.go)

install-ui::
npm ci
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You'll find everything you need in our [documentation](https://docs.evcc.io/) (G

## Contribute

To build evcc from source, [Go][1] 1.20 and [Node][2] 18 are required.
To build evcc from source, [Go][1] 1.21 and [Node][2] 18 are required.

Build and run go backend. The UI becomes available at http://127.0.0.1:7070/

Expand Down
2 changes: 1 addition & 1 deletion charger/easee/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package easee

import (
"fmt"
"slices"
"strings"

"github.com/philippseith/signalr"
"golang.org/x/exp/slices"
)

// Logger is a simple logger interface
Expand Down
2 changes: 1 addition & 1 deletion charger/warp2.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"encoding/json"
"errors"
"fmt"
"slices"
"time"

"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/charger/warp"
"github.com/evcc-io/evcc/provider"
"github.com/evcc-io/evcc/provider/mqtt"
"github.com/evcc-io/evcc/util"
"golang.org/x/exp/slices"
)

// Warp2 is the Warp charger v2 firmware implementation
Expand Down
2 changes: 1 addition & 1 deletion cmd/configure/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package configure
import (
"errors"
"fmt"
"slices"

"github.com/evcc-io/evcc/util/templates"
"golang.org/x/exp/slices"
)

// configureDeviceGuidedSetup lets the user choose a device that is set to support guided setup
Expand Down
2 changes: 1 addition & 1 deletion cmd/configure/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package configure

import (
"fmt"
"slices"
"sort"
"strings"

Expand All @@ -10,7 +11,6 @@ import (
"github.com/evcc-io/evcc/util/sponsor"
"github.com/evcc-io/evcc/util/templates"
stripmd "github.com/writeas/go-strip-markdown/v2"
"golang.org/x/exp/slices"
"gopkg.in/yaml.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/configure/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"os"
"slices"
"strconv"
"strings"

Expand All @@ -18,7 +19,6 @@ import (
"github.com/evcc-io/evcc/util/templates"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/text/language"
)

Expand Down
3 changes: 1 addition & 2 deletions cmd/configure/survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"os"
"slices"
"strconv"
"strings"
"time"
Expand All @@ -13,7 +14,6 @@ import (
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util/templates"
stripmd "github.com/writeas/go-strip-markdown/v2"
"golang.org/x/exp/slices"
)

// surveyAskOne asks the user for input
Expand All @@ -22,7 +22,6 @@ func (c *CmdConfigure) surveyAskOne(p survey.Prompt, response interface{}, opts
icons.Question.Text = ""
}))
err := survey.AskOne(p, response, opts...)

if err != nil {
if err == terminal.InterruptErr {
fmt.Println(c.localizedString("Cancel"))
Expand Down
7 changes: 4 additions & 3 deletions cmd/device.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package cmd

import (
"cmp"
"fmt"
"slices"
"strings"

"github.com/evcc-io/evcc/util/config"
"github.com/evcc-io/evcc/util/templates"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"
)

// deviceCmd represents the device debug command
Expand Down Expand Up @@ -49,8 +50,8 @@ func runDevice(cmd *cobra.Command, args []string) {
fmt.Printf("%d. %s\n", d.ID, d.Type)

details := d.Details
slices.SortFunc(details, func(i, j config.ConfigDetail) bool {
return i.Key < j.Key
slices.SortFunc(details, func(i, j config.ConfigDetail) int {
return cmp.Compare(i.Key, j.Key)
})

for _, d := range details {
Expand Down
2 changes: 1 addition & 1 deletion cmd/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package cmd

import (
"fmt"
"slices"
"strings"

"github.com/evcc-io/evcc/util/config"
"github.com/samber/lo"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"
"golang.org/x/oauth2"
)

Expand Down
3 changes: 2 additions & 1 deletion core/coordinator/adapter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package coordinator

import (
"slices"

"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/core/loadpoint"
"golang.org/x/exp/slices"
)

type adapter struct {
Expand Down
16 changes: 0 additions & 16 deletions core/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
"github.com/samber/lo"
"golang.org/x/exp/constraints"
)

var (
Expand Down Expand Up @@ -47,18 +46,3 @@ func vehicleTitles(vehicles []api.Vehicle) []string {
return v.Title()
})
}

// max of slice values
func max[T constraints.Ordered](s []T) T {
if len(s) == 0 {
var zero T
return zero
}
m := s[0]
for _, v := range s {
if v > m {
m = v
}
}
return m
}
10 changes: 5 additions & 5 deletions core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ func (lp *Loadpoint) setStatus(status api.ChargeStatus) {

// remainingChargeEnergy returns missing energy amount in kWh if vehicle has a valid energy target
func (lp *Loadpoint) remainingChargeEnergy() (float64, bool) {
return math.Max(0, lp.targetEnergy-lp.getChargedEnergy()/1e3),
return max(0, lp.targetEnergy-lp.getChargedEnergy()/1e3),
!lp.vehicleHasSoc() && lp.targetEnergy > 0
}

Expand Down Expand Up @@ -903,8 +903,8 @@ func (lp *Loadpoint) effectiveCurrent() float64 {

// adjust actual current for vehicles like Zoe where it remains below target
if lp.chargeCurrents != nil {
cur := max(lp.chargeCurrents)
return math.Min(cur+2.0, lp.chargeCurrent)
cur := max(lp.chargeCurrents[0], lp.chargeCurrents[1], lp.chargeCurrents[2])
return min(cur+2.0, lp.chargeCurrent)
}

return lp.chargeCurrent
Expand Down Expand Up @@ -1122,7 +1122,7 @@ func (lp *Loadpoint) pvMaxCurrent(mode api.ChargeMode, sitePower float64, batter
effectiveCurrent := lp.effectiveCurrent()
activePhases := lp.activePhases()
deltaCurrent := powerToCurrent(-sitePower, activePhases)
targetCurrent := math.Max(effectiveCurrent+deltaCurrent, 0)
targetCurrent := max(effectiveCurrent+deltaCurrent, 0)

lp.log.DEBUG.Printf("pv charge current: %.3gA = %.3gA + %.3gA (%.0fW @ %dp)", targetCurrent, effectiveCurrent, deltaCurrent, sitePower, activePhases)

Expand Down Expand Up @@ -1198,7 +1198,7 @@ func (lp *Loadpoint) pvMaxCurrent(mode api.ChargeMode, sitePower float64, batter
lp.resetPVTimer()

// cap at maximum current
targetCurrent = math.Min(targetCurrent, maxCurrent)
targetCurrent = min(targetCurrent, maxCurrent)

return targetCurrent
}
Expand Down
3 changes: 1 addition & 2 deletions core/loadpoint_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package core
import (
"errors"
"fmt"
"math"
"time"

"github.com/evcc-io/evcc/api"
Expand Down Expand Up @@ -316,7 +315,7 @@ func (lp *Loadpoint) GetChargePowerFlexibility() float64 {
}

// MinPV mode
return math.Max(0, lp.GetChargePower()-lp.GetMinPower())
return max(0, lp.GetChargePower()-lp.GetMinPower())
}

// GetMinCurrent returns the min loadpoint current
Expand Down
Loading

0 comments on commit e14fdf6

Please sign in to comment.