diff --git a/doc/go_spec.html b/doc/go_spec.html index e9b78b0deb2..8f2b062d966 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1256,6 +1256,14 @@ with compatible element type and at least one of V or T +

+If T is a struct type, either all fields of T +must be exported, or the assignment must be in +the same package in which T is declared. +In other words, a struct value can be assigned to a struct variable only if +every field of the struct may be legally assigned individually by the program. +

+

An untyped constant v is assignment compatible with type T if v @@ -1946,7 +1954,7 @@ Value = Expression . The LiteralType must be a struct, array, slice, or map type (the grammar enforces this constraint except when the type is given as a TypeName). -The types of the expressions must be assignment compatible to +The types of the expressions must be assignment compatible with the respective field, element, and key types of the LiteralType; there is no additional conversion. The key is interpreted as a field name for struct literals, @@ -2466,7 +2474,7 @@ f(a1, a2, ... an)

calls f with arguments a1, a2, ... an. The arguments must be single-valued expressions -assignment compatible with the parameters of +assignment compatible with the parameter types of F and are evaluated before the function is called. The type of the expression is the result type of F. @@ -3628,7 +3636,8 @@ map key, and the second variable, if present, is set to the corresponding string or array element or map value. The types of the array or slice index (always int) and element, or of the map key and value respectively, -must be assignment compatible to the iteration variables. +must be assignment compatible with +the type of the iteration variables.

For strings, the "range" clause iterates over the Unicode code points @@ -3798,8 +3807,9 @@ type:

  1. The return value or values may be explicitly listed in the "return" statement. Each expression must be single-valued - and assignment compatible to the corresponding element of - the result type of the function. + and assignment compatible + with the type of the corresponding element of the function's + result type.
     func simple_f() int {
     	return 2
    @@ -4174,10 +4184,11 @@ m := make(map[string] int, 100);  # map with initial space for 100 elements
     
     

    Go programs are constructed by linking together packages. -A package is in turn constructed from one or more source files that -together provide access to a set of types, constants, functions, -and variables. Those elements may be exported and used in -another package. +A package in turn is constructed from one or more source files +that together declare constants, types, variables and functions +belonging to the package and which are accessible in all files +of the same package. Those elements may be +exported and used in another package.

    Source file organization

    @@ -4286,31 +4297,6 @@ import _ "lib/math"
    -

    Multiple-file packages

    - -

    -If a package is constructed from multiple source files, -all names declared in the package block, not just uppercase ones, -are in scope in all the files in the package. -

    - -

    -If source file math1.go contains -

    -
    -package math
    -
    -const twoPi = 6.283185307179586
    -
    -function Sin(x float) float { return ... }
    -
    - -

    -then a second file math2.go also in -package math -may refer directly to Sin and twoPi. -

    -

    An example package