Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/reference to iterator variable causes pointer problems #14

Merged

Conversation

HerrNaN
Copy link
Contributor

@HerrNaN HerrNaN commented Mar 4, 2022

In go-pas-client we convert the public models from the user to the interal models used for the actual request. In this conversion, when converting the band alarms list we do this:

for i, bandAlarm := range t.BandAlarms {
   threshold.BandAlarms[i] = bandAlarm.ToInternal()
}

This causes a problem when the ToInternal function on bandAlarm operates on a pointer to the struct rather than the struct itself. The function return an object with values that point back into the iterator variable and when we have more than one item in the list these values are set to the last value that was set in the iterator variable.

@HerrNaN HerrNaN requested a review from j-sv March 4, 2022 08:44
Copy link
Contributor

@j-sv j-sv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do a check on test code coverage.

models/threshold_test.go Show resolved Hide resolved
@HerrNaN
Copy link
Contributor Author

HerrNaN commented Mar 4, 2022

image

@HerrNaN HerrNaN requested a review from j-sv March 4, 2022 10:34
@HerrNaN HerrNaN merged commit 9116394 into main Mar 4, 2022
@j-sv j-sv deleted the fix/reference-to-iterator-variable-causes-pointer-problems branch March 4, 2022 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants