diff --git a/cmd/detect/tasks/http.go b/cmd/detect/tasks/http.go index 5b2aa36c4..794bb8733 100644 --- a/cmd/detect/tasks/http.go +++ b/cmd/detect/tasks/http.go @@ -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} } diff --git a/cmd/detect/tasks/keba.go b/cmd/detect/tasks/keba.go index 74b7ceacd..fc1b40500 100644 --- a/cmd/detect/tasks/keba.go +++ b/cmd/detect/tasks/keba.go @@ -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, diff --git a/cmd/detect/tasks/modbus.go b/cmd/detect/tasks/modbus.go index c9bf5e4ca..7548c019b 100644 --- a/cmd/detect/tasks/modbus.go +++ b/cmd/detect/tasks/modbus.go @@ -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) } diff --git a/cmd/detect/tasks/mqtt.go b/cmd/detect/tasks/mqtt.go index 9d3bda4e2..70db7b105 100644 --- a/cmd/detect/tasks/mqtt.go +++ b/cmd/detect/tasks/mqtt.go @@ -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: diff --git a/cmd/detect/tasks/tcp.go b/cmd/detect/tasks/tcp.go index c22152b99..f1f1392d9 100644 --- a/cmd/detect/tasks/tcp.go +++ b/cmd/detect/tasks/tcp.go @@ -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) } diff --git a/cmd/detect/tasks/types.go b/cmd/detect/tasks/types.go index 4e17b2d07..759360e6a 100644 --- a/cmd/detect/tasks/types.go +++ b/cmd/detect/tasks/types.go @@ -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 diff --git a/go.mod b/go.mod index c16d1106d..580751f57 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index 72872cf82..ce1df833e 100644 --- a/go.sum +++ b/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=