chore: modernize

This commit is contained in:
andig 2026-05-01 18:03:19 +02:00
parent f332798dd0
commit 1169a3c8b9
4 changed files with 4 additions and 4 deletions

View file

@ -147,7 +147,7 @@ func (c *KebaUdp) roundtrip(msg string, report int, res any) error {
if report == 0 {
// use reflection to write to simple string
rv := reflect.ValueOf(res)
if rv.Kind() != reflect.Ptr || rv.IsNil() || rv.Elem().Kind() != reflect.String {
if rv.Kind() != reflect.Pointer || rv.IsNil() || rv.Elem().Kind() != reflect.String {
return fmt.Errorf("invalid type: %s", reflect.TypeOf(res))
}

View file

@ -210,7 +210,7 @@ func DecodeOtherSliceOrMap(other, res any) error {
val := reflect.ValueOf(other)
typ := reflect.TypeOf(other)
if typ.Kind() == reflect.Ptr {
if typ.Kind() == reflect.Pointer {
typ = typ.Elem()
val = reflect.Indirect(val)
}

View file

@ -131,7 +131,7 @@ func (m *Influx) writeComplexPoint(writer pointWriter, key string, val any, tags
switch typ := reflect.TypeOf(val); {
// pointer
case typ.Kind() == reflect.Ptr:
case typ.Kind() == reflect.Pointer:
if val := reflect.ValueOf(val); !val.IsNil() {
m.writeComplexPoint(writer, key, reflect.Indirect(val).Interface(), tags)
}

View file

@ -37,7 +37,7 @@ func (t *Tee) add(out chan<- Param) {
func (t *Tee) Run(in <-chan Param) {
for msg := range in {
// TODO MUST NOT PUBLISH POINTERS (WHO'S VALUES ARE LATER MODIFIED)
// if val := reflect.ValueOf(msg.Val); val.Kind() == reflect.Ptr {
// if val := reflect.ValueOf(msg.Val); val.Kind() == reflect.Pointer {
// if ptr := reflect.Indirect(val); ptr.IsValid() {
// fmt.Println("DANGER pointer value:", msg.Key)
// }