From 2132d9be985bc7c08ace8255c6e1cae04871bc8a Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 1 May 2026 17:58:00 +0200 Subject: [PATCH] chore: modernize --- charger/_blueprint.go | 2 +- charger/nrgble_linux.go | 10 +++++----- cmd/detect/definitions.go | 2 +- cmd/detect/tasks/registry.go | 2 +- meter/_blueprint.go | 2 +- plugin/aa55udp.go | 2 +- plugin/golang/stdlib/fmt.go | 12 ++++++------ 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/charger/_blueprint.go b/charger/_blueprint.go index 625d9651f..f448cf711 100644 --- a/charger/_blueprint.go +++ b/charger/_blueprint.go @@ -36,7 +36,7 @@ func init() { } // NewBlueprintFromConfig creates a blueprint charger from generic config -func NewBlueprintFromConfig(other map[string]interface{}) (api.Charger, error) { +func NewBlueprintFromConfig(other map[string]any) (api.Charger, error) { var cc struct { URI string Cache time.Duration diff --git a/charger/nrgble_linux.go b/charger/nrgble_linux.go index 580540c8a..97371cc01 100644 --- a/charger/nrgble_linux.go +++ b/charger/nrgble_linux.go @@ -40,7 +40,7 @@ func init() { } // NewNRGKickBLEFromConfig creates a NRGKickBLE charger from generic config -func NewNRGKickBLEFromConfig(other map[string]interface{}) (api.Charger, error) { +func NewNRGKickBLEFromConfig(other map[string]any) (api.Charger, error) { cc := struct{ Device, Mac, PIN string }{ Device: "hci0", } @@ -115,7 +115,7 @@ func (wb *NRGKickBLE) close() { } } -func (wb *NRGKickBLE) read(service string, res interface{}) error { +func (wb *NRGKickBLE) read(service string, res any) error { wb.mu.Lock() defer wb.mu.Unlock() @@ -135,7 +135,7 @@ func (wb *NRGKickBLE) read(service string, res interface{}) error { return err } - b, err := char.ReadValue(map[string]interface{}{}) + b, err := char.ReadValue(map[string]any{}) if err != nil { wb.close() return err @@ -145,7 +145,7 @@ func (wb *NRGKickBLE) read(service string, res interface{}) error { return struc.Unpack(bytes.NewReader(b), res) } -func (wb *NRGKickBLE) write(service string, val interface{}) error { +func (wb *NRGKickBLE) write(service string, val any) error { wb.mu.Lock() defer wb.mu.Unlock() @@ -171,7 +171,7 @@ func (wb *NRGKickBLE) write(service string, val interface{}) error { return err } - if err := char.WriteValue(out.Bytes(), map[string]interface{}{}); err != nil { + if err := char.WriteValue(out.Bytes(), map[string]any{}); err != nil { wb.close() return err } diff --git a/cmd/detect/definitions.go b/cmd/detect/definitions.go index fa3c771c2..d5be81da7 100644 --- a/cmd/detect/definitions.go +++ b/cmd/detect/definitions.go @@ -262,7 +262,7 @@ func init() { // ID: taskTPLink, // Type: tasks.Http, // Depends: TaskHttp, - // Config: map[string]interface{}{ + // Config: map[string]any{ // "ResponseHeader": map[string]string{ // "Server": "TP-LINK Smart Plug", // }, diff --git a/cmd/detect/tasks/registry.go b/cmd/detect/tasks/registry.go index 3e7bd026e..f3f7675a4 100644 --- a/cmd/detect/tasks/registry.go +++ b/cmd/detect/tasks/registry.go @@ -15,7 +15,7 @@ func (r TaskHandlerRegistry) Add(name TaskType, factory func(map[string]any) (Ta r[name] = factory } -// func (r TaskHandlerRegistry) Get(name string) (func(map[string]interface{}) (TaskHandler, error), error) { +// func (r TaskHandlerRegistry) Get(name string) (func(map[string]any) (TaskHandler, error), error) { // factory, exists := r[name] // if !exists { // return nil, fmt.Errorf("charger type not registered: %s", name) diff --git a/meter/_blueprint.go b/meter/_blueprint.go index b9636ecc6..030b5b11d 100644 --- a/meter/_blueprint.go +++ b/meter/_blueprint.go @@ -19,7 +19,7 @@ func init() { } // NewBlueprintFromConfig creates a blueprint meter from generic config -func NewBlueprintFromConfig(other map[string]interface{}) (api.Meter, error) { +func NewBlueprintFromConfig(other map[string]any) (api.Meter, error) { var cc struct { URI string Cache time.Duration diff --git a/plugin/aa55udp.go b/plugin/aa55udp.go index c8f384a51..1866ba4f5 100644 --- a/plugin/aa55udp.go +++ b/plugin/aa55udp.go @@ -50,7 +50,7 @@ func init() { // count: 2 # number of registers to read (1=U16, 2=S32/U32) // decode: int32be # int32be | uint32be | int16be | uint16be | float32be // scale: 1.0 # optional multiplier (default 1.0) -func NewAA55UDPFromConfig(_ context.Context, other map[string]interface{}) (Plugin, error) { +func NewAA55UDPFromConfig(_ context.Context, other map[string]any) (Plugin, error) { cc := struct { Host string `mapstructure:"host"` Id int `mapstructure:"id"` diff --git a/plugin/golang/stdlib/fmt.go b/plugin/golang/stdlib/fmt.go index dbf64f1aa..ebf1906c3 100644 --- a/plugin/golang/stdlib/fmt.go +++ b/plugin/golang/stdlib/fmt.go @@ -56,7 +56,7 @@ func init() { // _fmt_Formatter is an interface wrapper for Formatter type type _fmt_Formatter struct { - IValue interface{} + IValue any WFormat func(f fmt.State, verb rune) } @@ -66,7 +66,7 @@ func (W _fmt_Formatter) Format(f fmt.State, verb rune) { // _fmt_GoStringer is an interface wrapper for GoStringer type type _fmt_GoStringer struct { - IValue interface{} + IValue any WGoString func() string } @@ -76,7 +76,7 @@ func (W _fmt_GoStringer) GoString() string { // _fmt_ScanState is an interface wrapper for ScanState type type _fmt_ScanState struct { - IValue interface{} + IValue any WRead func(buf []byte) (n int, err error) WReadRune func() (r rune, size int, err error) WSkipSpace func() @@ -106,7 +106,7 @@ func (W _fmt_ScanState) Width() (wid int, ok bool) { // _fmt_Scanner is an interface wrapper for Scanner type type _fmt_Scanner struct { - IValue interface{} + IValue any WScan func(state fmt.ScanState, verb rune) error } @@ -116,7 +116,7 @@ func (W _fmt_Scanner) Scan(state fmt.ScanState, verb rune) error { // _fmt_State is an interface wrapper for State type type _fmt_State struct { - IValue interface{} + IValue any WFlag func(c int) bool WPrecision func() (prec int, ok bool) WWidth func() (wid int, ok bool) @@ -138,7 +138,7 @@ func (W _fmt_State) Write(b []byte) (n int, err error) { // _fmt_Stringer is an interface wrapper for Stringer type type _fmt_Stringer struct { - IValue interface{} + IValue any WString func() string }