Constants / iota / Essential Go
package main
import "fmt"
func main() {
const (
Secure = 1 << iota // 0b001
Authn // 0b010
Ready // 0b100
)
ConnState := Secure | Authn // 0b011: Connection is secure and authenticated, but not yet Ready
fmt.Printf(`Secure: 0x%x (0b%03b)
Authn: 0x%x (0b%03b)
ConnState: 0x%x (0b%03b)
`, Secure, Secure, Authn, Authn, ConnState, ConnState)
}INFO