diff --git a/api/beacon/beacon.go b/api/beacon/beacon.go index fc49863..c6a2763 100644 --- a/api/beacon/beacon.go +++ b/api/beacon/beacon.go @@ -58,12 +58,12 @@ func (b *Beacon) WatchDeviceChanges(ctx context.Context) (chan bool, error) { ch := make(chan bool) go func() { + defer close(ch) for { select { case changed := <-b.propchanged: if changed == nil { - ctx.Done() return } @@ -71,11 +71,9 @@ func (b *Beacon) WatchDeviceChanges(ctx context.Context) (chan bool, error) { ch <- b.Parse() } - break case <-ctx.Done(): b.propchanged <- nil - close(ch) - break + return } } }() diff --git a/util/map_struct.go b/util/map_struct.go index 498c861..bd04673 100644 --- a/util/map_struct.go +++ b/util/map_struct.go @@ -90,11 +90,11 @@ func mapStructField(obj interface{}, name string, value dbus.Variant) error { if val.Type().Kind() == reflect.Map { if structFieldType.Kind() == reflect.Struct || - (structFieldType.Kind() == reflect.Pointer && structFieldType.Elem().Kind() == reflect.Struct) { + (structFieldType.Kind() == reflect.Ptr && structFieldType.Elem().Kind() == reflect.Struct) { variantMap, ok := value.Value().(map[string]dbus.Variant) if ok { - if structFieldType.Kind() == reflect.Pointer { + if structFieldType.Kind() == reflect.Ptr { if structFieldValue.IsZero() { return fmt.Errorf("Pointer field %s: uninitialized", name) }