GitBucket
4.23.0
Toggle navigation
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
sample-golang
/
01_hello
Browse code
add iota sample
master
1 parent
9bfaab4
commit
cabd8cf2b77b06bfd60a7ffac3eec186f1dc36a7
yhornisse
authored
on 22 Sep 2021
Patch
Showing
1 changed file
iota.go
Ignore Space
Show notes
View
iota.go
0 → 100644
package main import "fmt" // enum的な type Weekday int64 const ( Sunday Weekday = iota // 0はじまり Monday // 1 Tuesday // 2 Wednesday // 3 Thursday // 4 Friday // 5 Saturday // 6 ) const ( _ = 1 << (10 * iota) // 1 << (10 * 0) KiB // 1 << (10 * 1) MiB // 1 << (10 * 2) GiB // 1 << (10 * 3) TiB // 1 << (10 * 4) ) func main() { // 0 1 2 3 4 5 6 fmt.Printf("%d %d %d %d %d %d %d\n", Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday) // 1024 1048576 1073741824 1099511627776 fmt.Printf("%d %d %d %d\n", KiB, MiB, GiB, TiB) }
Show line notes below