Skip to content

Commit 392191c

Browse files
committed
🎨 go-07
1 parent 0c912c4 commit 392191c

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
<a href="https://github.com/java-aodeng/golang-examples/blob/master/go-06/1.md">第06章 数组和切片</a> :<a href="https://t.zsxq.com/3N3jMB2">星球链接</a>
1414

15+
<a href="https://github.com/java-aodeng/golang-examples/blob/master/go-07/1.md">第07章 Map 声明、元素访问及遍历</a> :<a href="https://t.zsxq.com/qvvzZb2">星球链接</a>
16+
1517
## golang星球学习基地
1618
> 学习更多,快来星球吧,这个星球存在的意义只有一个:就是学习……
1719
1820
![](https://i.loli.net/2019/06/13/5d01b9fbec81470229.png)
1921

20-
第07章 Map 声明、元素访问及遍历 :<a href="https://t.zsxq.com/qvvzZb2">星球链接</a>
21-
2222
第08章 Map与工厂模式,在Go语言中实现Set :<a href="https://t.zsxq.com/qvvzZb2">星球链接</a>
2323

2424
第09章 字符串 :<a href="https://t.zsxq.com/qvvzZb2">星球链接</a>

go-07/1.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,20 @@
99

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

12-
## 1.1
12+
## 1.1 Map声明
13+
map key不存在,value默认会为0(重点注意)
1314

15+
m:=map[string]int{"a":1,"aa":2,"aaa":3}
16+
17+
m1:=map[string]int{}
18+
m1["a"]=1
19+
20+
```
21+
func TestMap(t *testing.T) {
22+
m:=map[string]int{"a":1,"aa":2,"aaa":3}
23+
t.Log(m["a"])
24+
}
25+
```
1426
## golang星球学习基地
1527
> 学习更多,快来星球吧,这个星球存在的意义只有一个:就是学习……
1628

go-07/map_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package go_07
2+
3+
import "testing"
4+
5+
func TestMap(t *testing.T) {
6+
m:=map[string]int{"a":1,"aa":2,"aaa":3}
7+
t.Log(m["a"])
8+
}
9+
10+
func TestTraveMap( t *testing.T) {
11+
m:=map[int]int{1:1,2:4,3:9}
12+
13+
for k,v:=range m {
14+
t.Log(k,v)
15+
}
16+
}

0 commit comments

Comments
 (0)