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.
While making my lights more awesome, I noticed a bug in
GetSchedules
that caused all items in thereturn
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 theSchedule
which is being reset as per therange
.There may be a more elegant fix, but simply assigning
s
to another variable and referencing that works hereWhile 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.