chore: modernize
This commit is contained in:
parent
f332798dd0
commit
1169a3c8b9
4 changed files with 4 additions and 4 deletions
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue