DEV Community

Discussion on: Bit Hacking with Go

Collapse
 
markuswa_ profile image
Markus

A note on 'Bits as Configuration' - instead of assigning the values 1, 2, 4 & 8 manually you can use iota.

const (
    FlagA = (1 << iota)
    FlagB
    FlagC
    ...
)
Enter fullscreen mode Exit fullscreen mode

Makes it easier to reorder and introduce new flags.

Collapse
 
vladimirvivien profile image
Vladimir Vivien

Markus, yes thanks for pointing that out.