[1725989] | 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 | |
---|
[7568e5c] | 22 | const ( R = 0; G = 3; B = 3; TT = 3 ) // implicit: 0 3 3 |
---|
[1725989] | 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 |
---|
[7568e5c] | 27 | Thu = 10; Fri = iota - Wed + Thu - 1; Sat; Sun = 0 ) // 10, 11, 12, 13 |
---|
[1725989] | 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() { |
---|
[7568e5c] | 36 | fmt.Println( "Go:") |
---|
[1725989] | 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; |
---|
[7568e5c] | 48 | day = Sun; |
---|
| 49 | |
---|
[1725989] | 50 | switch day { |
---|
| 51 | case Mon, Tue, Wed, Thu, Fri: |
---|
| 52 | fmt.Println( "weekday" ); |
---|
[7568e5c] | 53 | case Sat: |
---|
[1725989] | 54 | fmt.Println( "weekend" ); |
---|
| 55 | } |
---|
| 56 | for i := Mon; i <= Sun; i += 1 { |
---|
| 57 | fmt.Println( i ) |
---|
| 58 | } |
---|
[7568e5c] | 59 | fmt.Println(B < TT); |
---|
[1725989] | 60 | } // main |
---|
[7568e5c] | 61 | |
---|
| 62 | // go build test.go |
---|