如果第一个失败,Go 是否执行“if”中的所有条件?

Hug*_*anc -2 if-statement execution go

想象一下下面的一段代码:

if someBool && funcReturningABool() {
    // code here...
}
Run Code Online (Sandbox Code Playgroud)

wheresomeBool是一个布尔值并funcReturningABool返回真或假。

如果someBool等于false,funcReturningABool仍然会被执行吗?

Tit*_*lum 5

正如您可以在Golang 文档中找到

有条件地评估右操作数