chore: simplify (#19262)
This commit is contained in:
parent
783f79bee7
commit
a4a6bf1ab0
8 changed files with 7 additions and 23 deletions
|
|
@ -127,11 +127,7 @@ func (h *HttpHandler) Test(log *util.Logger, in ResultDetails) []ResultDetails {
|
|||
}
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
out := in.Clone()
|
||||
out.Port = port
|
||||
return []ResultDetails{out}
|
||||
}
|
||||
|
||||
return nil
|
||||
out := in
|
||||
out.Port = port
|
||||
return []ResultDetails{out}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ func (h *KEBAHandler) Test(log *util.Logger, in ResultDetails) []ResultDetails {
|
|||
continue
|
||||
}
|
||||
|
||||
out := in.Clone()
|
||||
out := in
|
||||
out.KebaResult = &KebaResult{
|
||||
Addr: t.Addr,
|
||||
Serial: t.Report.Serial,
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ func (h *ModbusHandler) Test(log *util.Logger, in ResultDetails) (res []ResultDe
|
|||
}
|
||||
|
||||
if ok {
|
||||
out := in.Clone()
|
||||
out := in
|
||||
out.ModbusResult = &mr
|
||||
res = append(res, out)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func (h *MqttHandler) Test(log *util.Logger, in ResultDetails) []ResultDetails {
|
|||
for {
|
||||
select {
|
||||
case <-recv:
|
||||
out := in.Clone()
|
||||
out := in
|
||||
out.Topic = h.Topic
|
||||
return []ResultDetails{out}
|
||||
case <-timer.C:
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func (h *TcpHandler) Test(_ *util.Logger, in ResultDetails) (res []ResultDetails
|
|||
}
|
||||
|
||||
if err == nil {
|
||||
out := in.Clone()
|
||||
out := in
|
||||
out.Port = port
|
||||
res = append(res, out)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package tasks
|
|||
|
||||
import (
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
type ResultDetails struct {
|
||||
|
|
@ -14,14 +13,6 @@ type ResultDetails struct {
|
|||
SmaResult *SmaResult `json:",omitempty"`
|
||||
}
|
||||
|
||||
func (d *ResultDetails) Clone() ResultDetails {
|
||||
var c ResultDetails
|
||||
if err := copier.Copy(&c, *d); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
Task
|
||||
ResultDetails
|
||||
|
|
|
|||
1
go.mod
1
go.mod
|
|
@ -53,7 +53,6 @@ require (
|
|||
github.com/insomniacslk/tapo v1.0.1
|
||||
github.com/itchyny/gojq v0.12.17
|
||||
github.com/jeremywohl/flatten v1.0.1
|
||||
github.com/jinzhu/copier v0.4.0
|
||||
github.com/jinzhu/now v1.1.5
|
||||
github.com/joeshaw/carwings v0.0.0-20250124122309-e366d592915c
|
||||
github.com/joho/godotenv v1.5.1
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -357,8 +357,6 @@ github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nu
|
|||
github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
|
||||
github.com/jeremywohl/flatten v1.0.1 h1:LrsxmB3hfwJuE+ptGOijix1PIfOoKLJ3Uee/mzbgtrs=
|
||||
github.com/jeremywohl/flatten v1.0.1/go.mod h1:4AmD/VxjWcI5SRB0n6szE2A6s2fsNHDLO0nAlMHgfLQ=
|
||||
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
|
||||
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue