github.com/nibnait/go-learn@v0.0.0-20220227013611-dfa47ea6d2da/src/test/chapter/ch1/03_constant_test.go (about) 1 package ch1 2 3 import "testing" 4 5 const ( 6 Monday = iota + 1 7 Tuesday 8 Wednesday 9 ) 10 11 func TestConstant1(t *testing.T) { 12 t.Log(Monday, Tuesday, Wednesday) 13 } 14 15 // --------------------------------------- // 16 17 const ( 18 Readable = 1 << iota 19 Writable 20 Executable 21 ) 22 23 func TestConstant2(t *testing.T) { 24 a := 7 // 0111 25 t.Log(a&Readable == Readable, 26 a&Writable == Writable, 27 a&Executable == Executable, 28 ) 29 }