2008-11-13 18:50:46 -07:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2008-12-02 17:49:44 -07:00
|
|
|
import (
|
|
|
|
"array"; // not needed
|
|
|
|
"utf8"; // not needed
|
|
|
|
Fmt "fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const /* enum */ (
|
|
|
|
EnumTag0 = iota;
|
|
|
|
EnumTag1;
|
|
|
|
EnumTag2;
|
|
|
|
EnumTag3;
|
|
|
|
EnumTag4;
|
|
|
|
EnumTag5;
|
|
|
|
EnumTag6;
|
|
|
|
EnumTag7;
|
|
|
|
EnumTag8;
|
|
|
|
EnumTag9;
|
|
|
|
)
|
2008-11-13 18:50:46 -07:00
|
|
|
|
|
|
|
|
2008-12-02 18:01:31 -07:00
|
|
|
type S struct {}
|
|
|
|
|
|
|
|
|
2008-11-13 18:50:46 -07:00
|
|
|
type T struct {
|
|
|
|
x, y int;
|
|
|
|
s string;
|
|
|
|
next_t *T
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
A = 5;
|
|
|
|
a, b, c int = 0, 0, 0;
|
|
|
|
foo = "foo";
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2008-11-26 18:07:45 -07:00
|
|
|
func f0(a, b int) int {
|
|
|
|
if a < b {
|
|
|
|
a = a + 1; // estimate
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-02 17:49:44 -07:00
|
|
|
func f1(tag int) {
|
|
|
|
switch tag {
|
|
|
|
case
|
|
|
|
EnumTag0, EnumTag1, EnumTag2, EnumTag3, EnumTag4,
|
|
|
|
EnumTag5, EnumTag6, EnumTag7, EnumTag8, EnumTag9: break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-13 18:50:46 -07:00
|
|
|
func main() {
|
2008-11-17 20:58:52 -07:00
|
|
|
// the prologue
|
2008-11-13 18:50:46 -07:00
|
|
|
for i := 0; i <= 10 /* limit */; i++ {
|
|
|
|
println(i); // the index
|
|
|
|
println(i + 1); // the index + 1
|
|
|
|
println(i + 1000); // the index + 1000
|
|
|
|
println();
|
|
|
|
}
|
2008-11-17 20:58:52 -07:00
|
|
|
// the epilogue
|
2008-11-13 18:50:46 -07:00
|
|
|
println("foo"); // foo
|
|
|
|
println("foobar"); // foobar
|
2008-11-26 18:07:45 -07:00
|
|
|
var x int; // declare x
|
2008-11-13 18:50:46 -07:00
|
|
|
}
|