Golang的空话是什么?

and*_*ndy 3 go

在Python中,我们可以使用pass子句作为占位符.
Golang中的等效条款是什么?
一个;还是别的什么?

pet*_*rSO 6

Go编程语言规范

空陈述

空语句什么都不做.

EmptyStmt =.

符号

使用Extended Backus-Naur Form(EBNF)指定语法:

Production  = production_name "=" [ Expression ] "." .
Expression  = Alternative { "|" Alternative } .
Alternative = Term { Term } .
Term        = production_name | token [ "…" token ] | Group | Option | Repetition .
Group       = "(" Expression ")" .
Option      = "[" Expression "]" .
Repetition  = "{" Expression "}" .
Run Code Online (Sandbox Code Playgroud)

Productions是由术语和以下运算符构成的表达式,优先级越来越高:

|   alternation
()  grouping
[]  option (0 or 1 times)
{}  repetition (0 to n times)
Run Code Online (Sandbox Code Playgroud)

小写生产名称用于识别词汇标记.非终端在CamelCase中.词汇标记用双引号""或后引号括起来.

形式a ... b表示从a到b的字符集作为替代.水平省略号...也在规范的其他地方用于非正式地表示未进一步指定的各种枚举或代码片段.角色......(与三个角色相对......)不是Go语言的标记.

空语句为空.在EBNF(Extended Backus-Naur Form)形式:EmptyStmt = .或空字符串.

例如,

for {
}

var no
if true {
} else {
    no = true
}
Run Code Online (Sandbox Code Playgroud)