Quick actions

cmd+k|ctrl+k

Navigation

Languages

Constants / iota / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-03-26T10:12:18Z

Updated

2019-03-26T10:12:18Z

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