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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue