Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (20 sloc) 840 Bytes

第07章 Map 声明、元素访问及遍历

.序:

开源协议:GPL-3.0

地址:[golang-examples] https://github.com/java-aodeng/golang-examples

作者:[低调小熊猫] https://github.com/java-aodeng

意义:分享知识,提升自己

1.1 Map声明

map key不存在,value默认会为0(重点注意)

m:=map[string]int{"a":1,"aa":2,"aaa":3}

m1:=map[string]int{} m1["a"]=1

func TestMap(t *testing.T)  {
	m:=map[string]int{"a":1,"aa":2,"aaa":3}
	t.Log(m["a"])
}

golang星球学习基地

学习更多,快来星球吧,这个星球存在的意义只有一个:就是学习……

You can’t perform that action at this time.