「Go言語」const識別子iotaのビット演算子左シフト(<<)を使うサンプル
書式
定数名=数字<<iota
使用例
package main
import "fmt"
const (
x=1<<iota
y=3<<iota
s
t
)
func main() {
fmt.Println("x =",x)
fmt.Println("y =",y)
fmt.Println("s =",s)
fmt.Println("t =",t)
}
実行結果
>go run test.go
x = 1
y = 6
s = 12
t = 24