fix: ineffective assignments#650
Conversation
puellanivis
left a comment
There was a problem hiding this comment.
Great catch! It’s probably because they’re unused that the bug was never spotted.
Just two tiny one-character pieces of lint, and 🤷♀️ yeah, if they’re unused, we can at least try deleting them. Being that the type itself is unexported, there’s really no reason to implement setters like this unless it needs to match an interface, and the interface doesn’t contain it… so… yeah. I say, chuck it and then we see what breaks. (Easy enough to put back.)
| } | ||
| func (p orderedRequest) orderID() uint32 { return p.orderid } | ||
| func (p orderedRequest) setOrderID(oid uint32) { p.orderid = oid } | ||
| func (p orderedRequest) orderID() uint32 { return p.orderid } |
There was a problem hiding this comment.
If we’re changing one receiver to a pointer receiver, then we should generally convert all of them to pointer receivers. (Unless there’s a good reason, like how lots of shallow clones are simply value receivers that return a pointer to their receiver… but now with new(*myPointer) not sure how useful that pattern is anymore.)
c89869b to
dbf7c75
Compare
|
I've rebased the commit to remove the two |
This fixes two functions that had a non-pointer receiver, preventing them from effectively updating fields on the
orderedResponse{}andorderedRequest{}structs.In looking at this, I realize that both of these functions are unused. I'd be happy to take the next step and remove them both.