package main import ( "flag" "fmt" ) func main() { var out uint32 pa := flag.Bool("a", false, "a") pb := flag.Bool("b", false, "b") pc := flag.Bool("c", false, "c") pd := flag.Bool("d", false, "d") flag.Parse() a := *pa b := *pb c := *pc d := *pd fmt.Printf("%t %t %t %t\n", a, b, c, d) // set each boolean to a bit in the input if a { out |= 0x1 } if b { out |= 0x2 } if c { out |= 0x4 } if d { out |= 0x8 } fmt.Printf("result: %b\n", out) }