6 ms·
I managed to track down the original code containing these snippets using the GitHub code search tool: https://github.com/adobe/kratos/blob/93246f92d53feba7374
by assbuttbuttass 3y ago
I managed to track down the original code containing these snippets using the GitHub code search tool:
https://github.com/adobe/kratos/blob/93246f92d53feba73743dbf3384e7044e9a05ea9/scale/scale_target.go#L98 https://github.com/adobe/kratos/blob/93246f92d53feba73743dbf...
https://github.com/StalkR/goircbot/blob/6081ed5d1d74f01767d70a1b3d5052d2fab42478/plugins/df/handlers.go#L110 https://github.com/StalkR/goircbot/blob/6081ed5d1d74f01767d7...
The difference is that in one case, informer is an interface, so the method call resolves informer.Run immediately and there's no issue. In the other case, a is a struct Alarm, and gets copied by value, and the Monitor method takes a pointer receiver. So my original intuition was right, the compiler is essentially translating
go a.Monitor(b)
into
go (&a).Monitor(b)
Which has a reference to the loop variable, and creates an issue.
- mighmi 3y agoCf. https://www.youtube.com/watch?v=0m6iFd9N_CY https://www.youtube.com/watch?v=0m6iFd9N_CY which features this code: func soldAnother(a *album) { a.copies++ // note the pointer. Can use dot notation on pointer, // equivalent to (*a).copies++)