You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the same way it is useful to compare pointers (and not their values), I came across a situation where I wanted to compare slices (and not their backing array's values), as if they were structs containing ptr, len and cap. Thus slices a == b, would be true iff a.ptr == b.ptr && a.len == b.len && a.cap == b.cap, regardless of what is contained in a or b's backing arrays. Lastly, since equality and inequality would be clearly defined, I could use slices as map keys, as changing the array data would be safe and have no impact on the keys themselves.
I was writing some temporary code that would proxy requests to an old system for third party communication drivers that hadn't yet been re-written into the new system. Requests from clients would be split out to the different drivers, but the request data slices would be shared between drivers.