Skip to content

Instantly share code, notes, and snippets.

Last active Apr 25, 2016
What would you like to do?
package bitmask
import (
type Channelmask struct {
A3 bool
A2 bool
A1 bool
A0 bool
func ParseMask(b []byte) (Channelmask) {
var mask Channelmask
buf := bytes.NewReader(b)
err := binary.Read(buf, binary.LittleEndian, &mask)
if err != nil {
fmt.Println("binary.Read failed:", err)
return mask
package bitmask
func TestParseMask(t *testing.T) {
var mask Channelmask
var mymask = []byte{0x01, 0x01}
mask = ParseMask(mymask)
fmt.Printf("%+v\n", mask)
mt.AssertEqual(t, true, mask.A0)
mt.AssertEqual(t, false, mask.A1)
mt.AssertEqual(t, true, mask.A2)
mt.AssertEqual(t, false, mask.A3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment