package ber // BitString type BitString []bool func UnmarshalBitString(b []byte) (bs BitString) { padding := int(b[0]) length := (len(b)-1)*8 - padding for i := 0; i < length; i++ { x := 1 + i/8 y := 7 - uint(i%8) bit := b[x]&(1< 0 && i%4 == 0 { s += " " } s += bmap[bit] } return } func (bs BitString) IsSet(n int) bool { if n > len(bs) { return false } return bs[n] } func pow2(n int) int { i := 1 for i < n+1 { i <<= 1 } return i } func (bs *BitString) Set(n int) { if len(*bs) < n { nbs := make(BitString, pow2(n)) copy(nbs, *bs) *bs = nbs } (*bs)[n] = true } func (bs *BitString) Clear(n int) { if len(*bs) < n { nbs := make(BitString, pow2(n)) copy(nbs, *bs) *bs = nbs } (*bs)[n] = false } func (bs BitString) Equal(s BitString) bool { if len(bs) != len(s) { return false } for i := 0; i < len(bs); i++ { if bs[i] != s[i] { return false } } return true }