This is a created article in which the information may have evolved or changed.
About the author
Program developers, not confined to language and technology, are currently mainly engaged in PHP and front-end development, using the Laravel and Vuejs,app end use Apicloud hybrid development. The right and enough is the never-ending pursuit. 2017.05.04 start learning go language in free time
Personal website: http://www.linganmin.cn
Recently wrote a mobile phone online play H5 movie station: Http://www.ifilm.ltd
package main/** * 声明变量方式 */// 第一种,指定变量类型,声明后赋值,若不赋值使用默认值var name string = "saboran"var age int // 默认值为0var address string // 默认值为空字符串// 第二种,根据值自行判断类型var sex = "male"var sister = 2// 第三种,省略var, := 左侧的变量不应该是已经声明过的,否则会编译错误//sex := "male" // 这种声明方式只能用在函数内部,否则编译报错/** * 多变量声明 */// 声明多个变量,自动判断类型var friendName, friendAge = "lingan",18// 声明多个变量,指定类型var ( friendSex string firendSister int)func main() { // 第一种定义的输出 println(name) println(age) println(address) // 第二种定义的输出 println(sex) println(sister) // 第三种定义输出 // 声明初始化多个变量输出 println(friendName) println(friendAge)}