MarshalJSON should produce unique result ID

Result variable inside for-loop actually have the same address on each iteration, so we need to take address in underlying slice.
This commit is contained in:
Mikhail 2023-04-06 18:20:54 +05:00 committed by demget
parent 78610849e1
commit e6590d806a

View File

@ -93,9 +93,9 @@ type Results []Result
// MarshalJSON makes sure IQRs have proper IDs and Type variables set.
func (results Results) MarshalJSON() ([]byte, error) {
for _, result := range results {
for i, result := range results {
if result.ResultID() == "" {
result.SetResultID(fmt.Sprintf("%d", &result))
result.SetResultID(fmt.Sprintf("%d", &results[i]))
}
if err := inferIQR(result); err != nil {
return nil, err