1 | package main |
---|
2 | import "fmt" |
---|
3 | |
---|
4 | // const R int = 0; |
---|
5 | // const G uint = 1; |
---|
6 | // const B = 2; |
---|
7 | // const Fred = "Fred"; |
---|
8 | // const Mary = "Mary"; |
---|
9 | // const Jane = "Jane"; |
---|
10 | // const S = 0; |
---|
11 | // const T = 0; |
---|
12 | // const USA = "USA"; |
---|
13 | // const U = "USA"; |
---|
14 | // const V = 3.1; |
---|
15 | // const W = 3.1; |
---|
16 | // |
---|
17 | // func main() { |
---|
18 | // fmt.Println( Mon, Tue, Wed ) |
---|
19 | // } // main |
---|
20 | |
---|
21 | |
---|
22 | const ( R = 0; G = 3; B = 3; TT = 3 ) // implicit: 0 3 3 |
---|
23 | const ( Fred = "Fred"; Mary = "Mary"; Jane = "Jane" ) // Fred Mary Jane |
---|
24 | const ( H = 0; Jack = "Jack"; J; K = 0; I ) // type change, implicit: 0 Jack Jack |
---|
25 | const ( C = iota + G; M = iota; Y ) |
---|
26 | const ( Mon = iota; Tue; Wed; // 0, 1, 2 |
---|
27 | Thu = 10; Fri = iota - Wed + Thu - 1; Sat; Sun = 0 ) // 10, 11, 12, 13 |
---|
28 | const ( O1 = iota + 1; _; O3; _; O5 ) // 1, 3, 5 |
---|
29 | const ( V1 = iota; V2; V3 = 7; V4 = iota + 1; V5 ) |
---|
30 | const ( S = 0; T; USA = "USA"; U; V = 3.1; W ) |
---|
31 | const ( D = 1.5; E ); |
---|
32 | |
---|
33 | |
---|
34 | |
---|
35 | func main() { |
---|
36 | fmt.Println( "Go:") |
---|
37 | if 3 == R {}; |
---|
38 | fmt.Println( R, G, B ) |
---|
39 | fmt.Println( Fred, Mary, Jane ) |
---|
40 | fmt.Println( H, Jack, J, K, I ) |
---|
41 | fmt.Println( C, M, Y ) |
---|
42 | fmt.Println( Mon, Tue, Wed, Thu, Fri, Sat, Sun ) |
---|
43 | fmt.Println( O1, O3, O5 ) |
---|
44 | fmt.Println( V1, V2, V3, V4, V5 ) |
---|
45 | fmt.Println( S, T, USA, U, V, W ) |
---|
46 | |
---|
47 | day := Mon; |
---|
48 | day = Sun; |
---|
49 | |
---|
50 | switch day { |
---|
51 | case Mon, Tue, Wed, Thu, Fri: |
---|
52 | fmt.Println( "weekday" ); |
---|
53 | case Sat: |
---|
54 | fmt.Println( "weekend" ); |
---|
55 | } |
---|
56 | for i := Mon; i <= Sun; i += 1 { |
---|
57 | fmt.Println( i ) |
---|
58 | } |
---|
59 | fmt.Println(B < TT); |
---|
60 | } // main |
---|
61 | |
---|
62 | // go build test.go |
---|