package main import ( "flag" "fmt" ) func main() { tests := make([]bool, 8) num := flag.Uint("v", 0, "flags to extract") flag.Parse() // input value, in binary var input uint8 = uint8(*num) fmt.Printf("val: %b\n", input) // set each boolean to a bit in the input tests[0] = (input & (1 << 0)) != 0 tests[1] = (input & (1 << 1)) != 0 tests[2] = (input & (1 << 2)) != 0 tests[3] = (input & (1 << 3)) != 0 tests[4] = (input & (1 << 4)) != 0 tests[5] = (input & (1 << 5)) != 0 tests[6] = (input & (1 << 6)) != 0 tests[7] = (input & (1 << 7)) != 0 fmt.Printf("result: %v\n", tests) for i, val := range tests { fmt.Printf("result %d: %t\n", i, val) } }