chore: upgrade Go to 1.27 (#30601)
This commit is contained in:
parent
748d36d130
commit
e63bae0c8b
37 changed files with 135 additions and 154 deletions
|
|
@ -266,7 +266,7 @@ func TestDsmrWebSocket(t *testing.T) {
|
|||
t.Run(tc.name, func(t *testing.T) {
|
||||
payload := dsmrFrame(dsmrTelegram50)
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
srv := httptest.NewTestServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
conn, err := websocket.Accept(w, r, nil)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -280,7 +280,7 @@ func TestDsmrWebSocket(t *testing.T) {
|
|||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
}))
|
||||
defer srv.Close()
|
||||
srv.Start()
|
||||
|
||||
uri := "ws" + strings.TrimPrefix(srv.URL, "http")
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ func (c *EEBus) lastCurtailPercent() int {
|
|||
return c.curtailPercent
|
||||
}
|
||||
|
||||
func (c *EEBus) readValue(scenario uint, update func(entity spineapi.EntityRemoteInterface) (float64, error)) (float64, error) {
|
||||
func (c *EEBus) readValue[T any](scenario uint, update func(entity spineapi.EntityRemoteInterface) (T, error)) (T, error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
return eebusReadValue(c.mm, c.maEntity, scenario, update)
|
||||
|
|
@ -205,10 +205,7 @@ func (c *EEBus) TotalEnergy() (float64, error) {
|
|||
}
|
||||
|
||||
func (c *EEBus) readPhases(scenario uint, update func(entity spineapi.EntityRemoteInterface) ([]float64, error)) (float64, float64, float64, error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
res, err := eebusReadValue(c.mm, c.maEntity, scenario, update)
|
||||
res, err := c.readValue(scenario, update)
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ type gen2 struct {
|
|||
emdata func() (Gen2EMData, error)
|
||||
}
|
||||
|
||||
func apiCall[T any](c *gen2, id int, method string) func() (T, error) {
|
||||
func (c *gen2) apiCall[T any](id int, method string) func() (T, error) {
|
||||
return func() (T, error) {
|
||||
var res T
|
||||
if err := c.execCmd(id, method, &res); err != nil {
|
||||
|
|
@ -152,9 +152,9 @@ func newGen2(helper *request.Helper, uri, model string, channel int, user, passw
|
|||
}
|
||||
|
||||
if c.hasMethod("PM1.GetStatus") {
|
||||
c.switchstatus = util.ResettableCached(apiCall[Gen2SwitchStatus](c, channel, "PM1.GetStatus"), cache)
|
||||
c.switchstatus = util.ResettableCached(c.apiCall[Gen2SwitchStatus](channel, "PM1.GetStatus"), cache)
|
||||
} else {
|
||||
c.switchstatus = util.ResettableCached(apiCall[Gen2SwitchStatus](c, c.switchchannel, "Switch.GetStatus"), cache)
|
||||
c.switchstatus = util.ResettableCached(c.apiCall[Gen2SwitchStatus](c.switchchannel, "Switch.GetStatus"), cache)
|
||||
}
|
||||
// device-side "Reverse power measurement" setting (requires restart, hence static)
|
||||
var cfgMethod string
|
||||
|
|
@ -177,10 +177,10 @@ func newGen2(helper *request.Helper, uri, model string, channel int, user, passw
|
|||
c.reversed = cfg.Reverse
|
||||
}
|
||||
|
||||
c.em1status = util.Cached(apiCall[Gen2EM1Status](c, channel, "EM1.GetStatus"), cache)
|
||||
c.em1data = util.Cached(apiCall[Gen2EM1Data](c, channel, "EM1Data.GetStatus"), cache)
|
||||
c.emstatus = util.Cached(apiCall[Gen2EMStatus](c, channel, "EM.GetStatus"), cache)
|
||||
c.emdata = util.Cached(apiCall[Gen2EMData](c, channel, "EMData.GetStatus"), cache)
|
||||
c.em1status = util.Cached(c.apiCall[Gen2EM1Status](channel, "EM1.GetStatus"), cache)
|
||||
c.em1data = util.Cached(c.apiCall[Gen2EM1Data](channel, "EM1Data.GetStatus"), cache)
|
||||
c.emstatus = util.Cached(c.apiCall[Gen2EMStatus](channel, "EM.GetStatus"), cache)
|
||||
c.emdata = util.Cached(c.apiCall[Gen2EMData](channel, "EMData.GetStatus"), cache)
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue