amimof / huego

An extensive Philips Hue client library for Go with an emphasis on simplicity
MIT License
250 stars 36 forks source link

fix bug in `GetSchedules` #15

Closed martinrhoads closed 4 years ago

martinrhoads commented 4 years ago

While making my lights more awesome, I noticed a bug in GetSchedules that caused all items in the return array to be the same *Schedule.

From this, I was able to derive this minimal repo.

As best as I can tell, the append is coping the pointer to the Schedule which is being reset as per the range.

There may be a more elegant fix, but simply assigning s to another variable and referencing that works here

While I was here, I noticed that the results were not ordered as go maps don't provide that. Since the Hue api returns ordered results, I made the behavior constient.

amimof commented 4 years ago

@martinrhoads This was fixed in https://github.com/amimof/huego/pull/12