Until I’ve found wonderful bitmap I was convinced there’s no good bitmask of arbitrary size implementation, so I’ve decided to implement my own.
Please,
import "github.com/astef/bitmask"
It looked much of a simple task in the beginning. From the very start I decided to make a Slice method, which would work in the same way slices work in Go - without copying internal store. Then, obviously, Copy function was introduced (what if I really need a copy, right?). Then I realised that copying overlapping ranges is a non-trivial task, and I’ve spent 80% of time on testing and fixing various corner cases. Looks quite ugly, but I promise you it’s correct (don’t trust me and propose a broken test).
My final conclusion from this journey is that I’m in love with Go, and such silly programming tasks is what I was missing in all my developer jobs.
What do you think about package and code? Will be happy to hear any opinion and participate in any issues you open about it.
Thanks!