Go语言是一种静态类型的编程语言
变量的定义
变量的定义用var关键字
var name type
var name string = "zhangsan"
变量的赋值
短变量的声明并初始化
// := 自动推导
name := "zhangsan"
age := 12
fmt.Println(name, age)
//打印内存地址
fmt.Printf("%d,%p",num,&num)
变量的交换
Go语言的变量交换
var a, b int
a = 100
b = 200
b, a = a, b
fmt.Println(a, b)
iota
iota是go语言的常量计数器
const (
a = iota //iota = 0
b //iota = 1
c //iota = 2
d //iota = 3
e = "come" //come iota = 4
f //come iota = 5
g //come iota = 6
h = iota //iota = 7
i //iota = 8
j //iota = 9
)
const (
k = iota //iota = 0
l //iota = 1
m //iota = 2
n
o
)
标签:变量,name,var,go,come,iota,语言
From: https://www.cnblogs.com/xiaomeng--8/p/16993216.html