Skip to content

Commit

Permalink
Fix accessing unexported fields
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Oct 29, 2023
1 parent e7dd976 commit a844c0d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a844c0d

Please sign in to comment.