Fix accessing unexported fields
Some checks failed
Some checks failed
This commit is contained in:
parent
e7dd9762d6
commit
a844c0ddbf
1 changed files with 4 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue