[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 | |
---|
[dcfcf368] | 22 | const ( R int = 0; G = 3; B = 3; TT = 3 ) // implicit: 0 3 3 |
---|
| 23 | const ( Fred string = "Fred"; Mary = "Mary"; Jane = "Jane" ) // Fred Mary Jane |
---|
[1725989] | 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 | |
---|
[dcfcf368] | 33 | const ( AA int = 3; KK; BB float32 = 3.5; CC = 3.9 ); |
---|
| 34 | type BigInt int64 |
---|
[1725989] | 35 | |
---|
| 36 | func main() { |
---|
[7568e5c] | 37 | fmt.Println( "Go:") |
---|
[1725989] | 38 | if 3 == R {}; |
---|
[dcfcf368] | 39 | fmt.Println( AA, KK, BB, CC ) |
---|
[1725989] | 40 | fmt.Println( R, G, B ) |
---|
| 41 | fmt.Println( Fred, Mary, Jane ) |
---|
| 42 | fmt.Println( H, Jack, J, K, I ) |
---|
| 43 | fmt.Println( C, M, Y ) |
---|
| 44 | fmt.Println( Mon, Tue, Wed, Thu, Fri, Sat, Sun ) |
---|
| 45 | fmt.Println( O1, O3, O5 ) |
---|
| 46 | fmt.Println( V1, V2, V3, V4, V5 ) |
---|
| 47 | fmt.Println( S, T, USA, U, V, W ) |
---|
| 48 | |
---|
| 49 | day := Mon; |
---|
[7568e5c] | 50 | day = Sun; |
---|
| 51 | |
---|
[1725989] | 52 | switch day { |
---|
| 53 | case Mon, Tue, Wed, Thu, Fri: |
---|
| 54 | fmt.Println( "weekday" ); |
---|
[7568e5c] | 55 | case Sat: |
---|
[1725989] | 56 | fmt.Println( "weekend" ); |
---|
| 57 | } |
---|
| 58 | for i := Mon; i <= Sun; i += 1 { |
---|
| 59 | fmt.Println( i ) |
---|
| 60 | } |
---|
[7568e5c] | 61 | fmt.Println(B < TT); |
---|
[1725989] | 62 | } // main |
---|
[7568e5c] | 63 | |
---|
[dcfcf368] | 64 | // go build test.go |
---|