I'm trying to work out how to get the bitmask values from a const with go enumeration. For example, if key is 5, which is 0101 bits, it would be dog and fish. What is the easiest way to get the bit values (1,2,4,8,16, 32, 64 etc) so I can select the string values and return the set of animals?
type Key int const ( Dog Key = 1 << iota Cat Fish Horse Snake Rabbit Lion Rino Hedgehog )
Been reading but I can't work this out.