Fix accessing unexported fields
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
andig 2023-10-29 10:21:01 +01:00
parent e7dd9762d6
commit a844c0ddbf

View file

@ -93,8 +93,10 @@ func (m *MQTT) publishComplex(topic string, retained bool, payload interface{})
// loop struct
for i := 0; i < typ.NumField(); i++ {
n := typ.Field(i).Name
m.publishComplex(fmt.Sprintf("%s/%s", topic, strings.ToLower(n[:1])+n[1:]), retained, val.Field(i).Interface())
if f := typ.Field(i); f.IsExported() {
n := f.Name
m.publishComplex(fmt.Sprintf("%s/%s", topic, strings.ToLower(n[:1])+n[1:]), retained, val.Field(i).Interface())
}
}
default: