golang中的var()是什么意思

What't the means about var () in golang

我查看了 go-swagger 生成的代码,发现如下代码:

// NewReceiveLearningLabActsParams creates a new ReceiveLearningLabActsParams object
// with the default values initialized.
func NewReceiveLearningLabActsParams() ReceiveLearningLabActsParams {
    var ()
    return ReceiveLearningLabActsParams{}
}

我注意到这里:

var ()

我完全不明白这是什么意思,谁能帮我理解这段代码?谢谢

在 Go 中,这是一个 shorthand 用于批量定义变量。 不必在每个变量声明前写 var,您可以使用 var 声明块。

例如:

var (
    a,b,c string = "this ", "is ","it "
    e,f,g int = 1, 2, 3
)

相同
var a,b,c string = "this ", "is ","it "
var d,e,f int = 1, 2, 3

您的代码示例中的 var () 只是声明未声明任何变量。

有关详细信息,请参阅 the official Go documentation