The error message "cannot initialize 2 variables with 1 value" is returned by the Go compiler when you try to assign an insufficient number of values to multiple variables during initialization.

In Go, when initializing multiple variables, you need to provide the same number of values as the number of variables being initialized. For example:

var a, b int = 10, 20 // Correct initialization

var c, d int = 30 // Incorrect initialization, only one value provided

In the incorrect initialization, you are trying to assign only one value to two variables (c and d), which is not allowed. To fix this error, make sure you provide the correct number of values for the variables being initialized

go语言annot initialize 2 variables with 1 valuescompilerWrongAssignCount

原文地址: http://www.cveoy.top/t/topic/iZOj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录