In Go, is it possible to define a custom type with several bits different from those offered byte uint uint16
or by any other built-in type?
I plan to use "enough bits" to represent variables and I need a 6-bit and 4-bit type. Perhaps a complex bool type?
type fourbit struct{
ones bool
twos bool
fours bool
eights bool
}
Although this kind of thing is pretty dirty, it would be nice to have a more general solution for n-bit types.
source
share