1
1
<!--{
2
2
"Title": "The Go Programming Language Specification",
3
- "Subtitle": "Language version go1.24 (Nov 20 , 2024)",
3
+ "Subtitle": "Language version go1.24 (Dec 12 , 2024)",
4
4
"Path": "/ref/spec"
5
5
}-->
6
6
@@ -810,12 +810,12 @@ <h2 id="Types">Types</h2>
810
810
</ p >
811
811
812
812
< pre class ="ebnf ">
813
- Type = TypeName [ TypeArgs ] | TypeLit | "(" Type ")" .
814
- TypeName = identifier | QualifiedIdent .
815
- TypeArgs = "[" TypeList [ "," ] "]" .
816
- TypeList = Type { "," Type } .
817
- TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType |
818
- SliceType | MapType | ChannelType .
813
+ Type = TypeName [ TypeArgs ] | TypeLit | "(" Type ")" .
814
+ TypeName = identifier | QualifiedIdent .
815
+ TypeArgs = "[" TypeList [ "," ] "]" .
816
+ TypeList = Type { "," Type } .
817
+ TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType |
818
+ SliceType | MapType | ChannelType .
819
819
</ pre >
820
820
821
821
< p >
@@ -1222,12 +1222,12 @@ <h3 id="Function_types">Function types</h3>
1222
1222
</ p >
1223
1223
1224
1224
< pre class ="ebnf ">
1225
- FunctionType = "func" Signature .
1226
- Signature = Parameters [ Result ] .
1227
- Result = Parameters | Type .
1228
- Parameters = "(" [ ParameterList [ "," ] ] ")" .
1229
- ParameterList = ParameterDecl { "," ParameterDecl } .
1230
- ParameterDecl = [ IdentifierList ] [ "..." ] Type .
1225
+ FunctionType = "func" Signature .
1226
+ Signature = Parameters [ Result ] .
1227
+ Result = Parameters | Type .
1228
+ Parameters = "(" [ ParameterList [ "," ] ] ")" .
1229
+ ParameterList = ParameterDecl { "," ParameterDecl } .
1230
+ ParameterDecl = [ IdentifierList ] [ "..." ] Type .
1231
1231
</ pre >
1232
1232
1233
1233
< p >
@@ -1634,8 +1634,8 @@ <h3 id="Map_types">Map types</h3>
1634
1634
</ p >
1635
1635
1636
1636
< pre class ="ebnf ">
1637
- MapType = "map" "[" KeyType "]" ElementType .
1638
- KeyType = Type .
1637
+ MapType = "map" "[" KeyType "]" ElementType .
1638
+ KeyType = Type .
1639
1639
</ pre >
1640
1640
1641
1641
< p >
@@ -2176,7 +2176,7 @@ <h2 id="Blocks">Blocks</h2>
2176
2176
</ p >
2177
2177
2178
2178
< pre class ="ebnf ">
2179
- Block = "{" StatementList "}" .
2179
+ Block = "{" StatementList "}" .
2180
2180
StatementList = { Statement ";" } .
2181
2181
</ pre >
2182
2182
@@ -2233,8 +2233,8 @@ <h2 id="Declarations_and_scope">Declarations and scope</h2>
2233
2233
</ p >
2234
2234
2235
2235
< pre class ="ebnf ">
2236
- Declaration = ConstDecl | TypeDecl | VarDecl .
2237
- TopLevelDecl = Declaration | FunctionDecl | MethodDecl .
2236
+ Declaration = ConstDecl | TypeDecl | VarDecl .
2237
+ TopLevelDecl = Declaration | FunctionDecl | MethodDecl .
2238
2238
</ pre >
2239
2239
2240
2240
< p >
@@ -2679,9 +2679,9 @@ <h3 id="Type_parameter_declarations">Type parameter declarations</h3>
2679
2679
</ p >
2680
2680
2681
2681
< pre class ="ebnf ">
2682
- TypeParameters = "[" TypeParamList [ "," ] "]" .
2683
- TypeParamList = TypeParamDecl { "," TypeParamDecl } .
2684
- TypeParamDecl = IdentifierList TypeConstraint .
2682
+ TypeParameters = "[" TypeParamList [ "," ] "]" .
2683
+ TypeParamList = TypeParamDecl { "," TypeParamDecl } .
2684
+ TypeParamDecl = IdentifierList TypeConstraint .
2685
2685
</ pre >
2686
2686
2687
2687
< p >
@@ -2869,8 +2869,8 @@ <h3 id="Variable_declarations">Variable declarations</h3>
2869
2869
</ p >
2870
2870
2871
2871
< pre class ="ebnf ">
2872
- VarDecl = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) .
2873
- VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
2872
+ VarDecl = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) .
2873
+ VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
2874
2874
</ pre >
2875
2875
2876
2876
< pre >
@@ -3210,15 +3210,15 @@ <h3 id="Composite_literals">Composite literals</h3>
3210
3210
</ p >
3211
3211
3212
3212
< pre class ="ebnf ">
3213
- CompositeLit = LiteralType LiteralValue .
3214
- LiteralType = StructType | ArrayType | "[" "..." "]" ElementType |
3215
- SliceType | MapType | TypeName [ TypeArgs ] .
3216
- LiteralValue = "{" [ ElementList [ "," ] ] "}" .
3217
- ElementList = KeyedElement { "," KeyedElement } .
3218
- KeyedElement = [ Key ":" ] Element .
3219
- Key = FieldName | Expression | LiteralValue .
3220
- FieldName = identifier .
3221
- Element = Expression | LiteralValue .
3213
+ CompositeLit = LiteralType LiteralValue .
3214
+ LiteralType = StructType | ArrayType | "[" "..." "]" ElementType |
3215
+ SliceType | MapType | TypeName [ TypeArgs ] .
3216
+ LiteralValue = "{" [ ElementList [ "," ] ] "}" .
3217
+ ElementList = KeyedElement { "," KeyedElement } .
3218
+ KeyedElement = [ Key ":" ] Element .
3219
+ Key = FieldName | Expression | LiteralValue .
3220
+ FieldName = identifier .
3221
+ Element = Expression | LiteralValue .
3222
3222
</ pre >
3223
3223
3224
3224
< p >
@@ -3450,22 +3450,21 @@ <h3 id="Primary_expressions">Primary expressions</h3>
3450
3450
</ p >
3451
3451
3452
3452
< pre class ="ebnf ">
3453
- PrimaryExpr =
3454
- Operand |
3455
- Conversion |
3456
- MethodExpr |
3457
- PrimaryExpr Selector |
3458
- PrimaryExpr Index |
3459
- PrimaryExpr Slice |
3460
- PrimaryExpr TypeAssertion |
3461
- PrimaryExpr Arguments .
3453
+ PrimaryExpr = Operand |
3454
+ Conversion |
3455
+ MethodExpr |
3456
+ PrimaryExpr Selector |
3457
+ PrimaryExpr Index |
3458
+ PrimaryExpr Slice |
3459
+ PrimaryExpr TypeAssertion |
3460
+ PrimaryExpr Arguments .
3462
3461
3463
- Selector = "." identifier .
3464
- Index = "[" Expression [ "," ] "]" .
3465
- Slice = "[" [ Expression ] ":" [ Expression ] "]" |
3466
- "[" [ Expression ] ":" Expression ":" Expression "]" .
3467
- TypeAssertion = "." "(" Type ")" .
3468
- Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" .
3462
+ Selector = "." identifier .
3463
+ Index = "[" Expression [ "," ] "]" .
3464
+ Slice = "[" [ Expression ] ":" [ Expression ] "]" |
3465
+ "[" [ Expression ] ":" Expression ":" Expression "]" .
3466
+ TypeAssertion = "." "(" Type ")" .
3467
+ Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" .
3469
3468
</ pre >
3470
3469
3471
3470
@@ -3638,8 +3637,8 @@ <h3 id="Method_expressions">Method expressions</h3>
3638
3637
</ p >
3639
3638
3640
3639
< pre class ="ebnf ">
3641
- MethodExpr = ReceiverType "." MethodName .
3642
- ReceiverType = Type .
3640
+ MethodExpr = ReceiverType "." MethodName .
3641
+ ReceiverType = Type .
3643
3642
</ pre >
3644
3643
3645
3644
< p >
@@ -5916,11 +5915,10 @@ <h2 id="Statements">Statements</h2>
5916
5915
</ p >
5917
5916
5918
5917
< pre class ="ebnf ">
5919
- Statement =
5920
- Declaration | LabeledStmt | SimpleStmt |
5921
- GoStmt | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt |
5922
- FallthroughStmt | Block | IfStmt | SwitchStmt | SelectStmt | ForStmt |
5923
- DeferStmt .
5918
+ Statement = Declaration | LabeledStmt | SimpleStmt |
5919
+ GoStmt | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt |
5920
+ FallthroughStmt | Block | IfStmt | SwitchStmt | SelectStmt | ForStmt |
5921
+ DeferStmt .
5924
5922
5925
5923
SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | ShortVarDecl .
5926
5924
</ pre >
@@ -6132,7 +6130,7 @@ <h3 id="Assignment_statements">Assignment statements</h3>
6132
6130
< pre class ="ebnf ">
6133
6131
Assignment = ExpressionList assign_op ExpressionList .
6134
6132
6135
- assign_op = [ add_op | mul_op ] "=" .
6133
+ assign_op = [ add_op | mul_op ] "=" .
6136
6134
</ pre >
6137
6135
6138
6136
< p >
@@ -6548,7 +6546,7 @@ <h3 id="For_statements">For statements</h3>
6548
6546
</ p >
6549
6547
6550
6548
< pre class ="ebnf ">
6551
- ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
6549
+ ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
6552
6550
Condition = Expression .
6553
6551
</ pre >
6554
6552
@@ -6580,8 +6578,8 @@ <h4 id="For_clause">For statements with <code>for</code> clause</h4>
6580
6578
6581
6579
< pre class ="ebnf ">
6582
6580
ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ] .
6583
- InitStmt = SimpleStmt .
6584
- PostStmt = SimpleStmt .
6581
+ InitStmt = SimpleStmt .
6582
+ PostStmt = SimpleStmt .
6585
6583
</ pre >
6586
6584
6587
6585
< pre >
@@ -7909,7 +7907,7 @@ <h3 id="Source_file_organization">Source file organization</h3>
7909
7907
</ p >
7910
7908
7911
7909
< pre class ="ebnf ">
7912
- SourceFile = PackageClause ";" { ImportDecl ";" } { TopLevelDecl ";" } .
7910
+ SourceFile = PackageClause ";" { ImportDecl ";" } { TopLevelDecl ";" } .
7913
7911
</ pre >
7914
7912
7915
7913
< h3 id ="Package_clause "> Package clause</ h3 >
@@ -7920,8 +7918,8 @@ <h3 id="Package_clause">Package clause</h3>
7920
7918
</ p >
7921
7919
7922
7920
< pre class ="ebnf ">
7923
- PackageClause = "package" PackageName .
7924
- PackageName = identifier .
7921
+ PackageClause = "package" PackageName .
7922
+ PackageName = identifier .
7925
7923
</ pre >
7926
7924
7927
7925
< p >
@@ -7950,9 +7948,9 @@ <h3 id="Import_declarations">Import declarations</h3>
7950
7948
</ p >
7951
7949
7952
7950
< pre class ="ebnf ">
7953
- ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
7954
- ImportSpec = [ "." | PackageName ] ImportPath .
7955
- ImportPath = string_lit .
7951
+ ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
7952
+ ImportSpec = [ "." | PackageName ] ImportPath .
7953
+ ImportPath = string_lit .
7956
7954
</ pre >
7957
7955
7958
7956
< p >
0 commit comments