func main() { … }
var x = a
var a, b = f() // a and b are initialized together, before x is initialized
var (
a = c + b // == 9
b = f() // == 4
c = f() // == 5
d = 3 // == 5 after initialization has finished
)
func f() int {
d++
return d
}
var x = I(T{}).ab() // x has an undetected, hidden dependency on a and b
var _ = sideEffect() // unrelated to x, a, or b
var a = b
var b = 42
type I interface { ab() []int }
type T struct{}
func (T) ab() []int { return []int{a, b} }
func init() { … }
t.i == 0
t.f == 0.0
t.next == nil
var t T
var i int
var i int = 0
type T struct { i int; f float64; next *T }
t := new(T)
ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
ImportSpec = [ "." | PackageName ] ImportPath .
ImportPath = string_lit .
Recommend
The Go Programming Language Specification Program initialization and execution The zero value
The Go Programming Language Specification Packages An example package
The Go Programming Language Specification Packages Import declarations
The Go Programming Language Specification Packages Package clause
The Go Programming Language Specification Packages Source file organization
The Go Programming Language Specification Built-in functions Bootstrapping
The Go Programming Language Specification Built-in functions Handling panics
The Go Programming Language Specification Built-in functions Manipulating complex numbers
The Go Programming Language Specification Built-in functions Deletion of map elements
The Go Programming Language Specification Built-in functions Appending to and copying slices
The Go Programming Language Specification Built-in functions Making slices, maps and channels
The Go Programming Language Specification Built-in functions Allocation
The Go Programming Language Specification Built-in functions Length and capacity
The Go Programming Language Specification Statements Defer statements
The Go Programming Language Specification Statements Fallthrough statements
The Go Programming Language Specification Statements Goto statements
The Go Programming Language Specification Statements Continue statements
The Go Programming Language Specification Statements Break statements
The Go Programming Language Specification Statements Return statements
The Go Programming Language Specification Statements Select statements
The Go Programming Language Specification Statements Go statements
The Go Programming Language Specification Statements For statements For statements with range clause
The Go Programming Language Specification Statements For statements For statements with for clause
The Go Programming Language Specification Statements For statements
The Go Programming Language Specification Statements Switch statements Type switches
The Go Programming Language Specification Statements Switch statements Expression switches
The Go Programming Language Specification Statements Switch statements
The Go Programming Language Specification Statements If statements
The Go Programming Language Specification Statements Assignments
The Go Programming Language Specification Statements IncDec statements
The Go Programming Language Specification Statements Send statements
The Go Programming Language Specification Statements Expression statements
The Go Programming Language Specification Statements Labeled statements
The Go Programming Language Specification Statements Empty statements
The Go Programming Language Specification Statements
The Go Programming Language Specification Expressions Order of evaluation
The Go Programming Language Specification Expressions Constant expressions
The Go Programming Language Specification Expressions Conversions
The Go Programming Language Specification Expressions Receive operator