File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 1
1
package client
2
2
3
3
import (
4
- cm "github.com/easierway/concurrent_map" //还可以导入第三方的包,这是导入一个开源项目的包,会自动git clone到本地
5
- "series" //这是导入自定义的包 路径,golang-examples\src\series
4
+ "series" //1.这是导入自定义的包 路径,golang-examples\src\series
6
5
"testing"
7
6
)
8
7
9
8
//package(包)
10
9
//1.基本复用模块单元
11
- //2以首字母大写来表明可被包外代码访问
10
+ //2.以首字母大写来表明可被包外代码访问
12
11
//3.代码的package可以和所在目录不一致
13
12
//4.同一目录里的Go代码package要保持一致
14
13
//5.创建包前需要配置项目GOPATH路径 配置教程 https://www.freesion.com/article/4765574656/
@@ -18,11 +17,13 @@ func TestPackage(t *testing.T) {
18
17
//调用golang-examples\src\series包里面的的Square函数
19
18
t .Log (series .Square (1 ))
20
19
21
- //t.Log(series.square(1)) 运行结果:undefined: series.square 小写的函数外部不能访问
20
+ //小写的函数外部不能访问
21
+ //t.Log(series.square(1)) 运行结果:undefined: series.square
22
22
23
- m := cm .CreateConcurrentMap (99 )
24
- m .Set (cm .StrKey ("key" ), 10 )
25
- t .Log (m .Get (cm .StrKey ("key" )))
23
+ //使用远程的包函数
24
+ //m := cm.CreateConcurrentMap(99)
25
+ //m.Set(cm.StrKey("key"), 10)
26
+ //t.Log(m.Get(cm.StrKey("key")))
26
27
}
27
28
28
29
//运行结果
You can’t perform that action at this time.
0 commit comments