File tree Expand file tree Collapse file tree 6 files changed +74
-2
lines changed Expand file tree Collapse file tree 6 files changed +74
-2
lines changed Original file line number Diff line number Diff line change 22
22
/nbdist /
23
23
/.nb-gradle /
24
24
25
- # #
25
+ # # 忽略包文件,不提交
26
+ bin
27
+ pkg
28
+ src /github.com
29
+ src /go-19 /module_package /vendor
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ ps:白天上班,晚上更新,尽量日更,比心
51
51
52
52
[ 第18章 构建可复用的模块(包)] ( https://github.com/java-aodeng/golang-examples/blob/master/go-18/client/package_test.go )
53
53
54
- 第19章 依赖管理
54
+ [ 第19章 依赖管理] ( https://github.com/java-aodeng/golang-examples/blob/master/go-19/module_package/get_remote_pack_test.go )
55
55
56
56
第20章 协程机制
57
57
Original file line number Diff line number Diff line change
1
+ 因为 go 编译器默认会在当前目录中查找src目录下package。 果没有src目录,编译器就找不到相应的package
2
+ 所以使用到包的章节都放在src目录下面了
3
+
Original file line number Diff line number Diff line change
1
+ package module_package
2
+
3
+ import (
4
+ cm "github.com/easierway/concurrent_map"
5
+ "testing"
6
+ )
7
+
8
+ //因为 go 编译器默认会在当前目录中查找src目录下package。 果没有src目录,编译器就找不到相应的package
9
+ //所以关于包的章节都放在src目录下面了
10
+
11
+ /*依赖管理
12
+ Go未解决的依赖问题
13
+ 1.同一环境下,不同项目使用同一包的不同版本
14
+ 2.无法管理对包的特定版本的依赖
15
+
16
+ vendor路径
17
+ 随着Go 1.5release版本的发布,vendor目录被添加到除GOPAHR和GOROOT之外的依赖目录查找的解决方案
18
+ 在Go 1.6之前,你需要手动的设置环境变量
19
+
20
+ 查找依赖包路径的解决方案如下:
21
+ 1.当前包的vendor目录
22
+ 2.向上目录查找,直到找到src下的vendor目录
23
+ 3.GOPATH下面查找依赖包
24
+ 4.GOROOT下面查找依赖包
25
+
26
+ 常用的依赖管理工具
27
+ dodep:https://github.com/tools/godep
28
+ glide:https://github.com/Masterminds/glide
29
+ dep:https://github.com/golang/dep
30
+
31
+ window安装glide教程: https://www.cnblogs.com/nickchou/p/8955180.html
32
+ 安装成功后,我们把src/github.com/easierway包的源文件删除,
33
+ 在go-19/module_package目录下执行
34
+ glide init
35
+ glide install
36
+ 会重新下载包源文件到项目go-19/vendor目录下
37
+
38
+ 遇到的问题:解决go build不去vendor下查找包的问题: https://www.jb51.net/article/202458.htm
39
+ 问题总结:go 编译器默认会在当前目录中查找src目录下package。如果没有src目录,编译器就找不到相应的package
40
+
41
+
42
+ */
43
+ func TestConcurrentMap (t * testing.T ) {
44
+
45
+ m := cm .CreateConcurrentMap (99 )
46
+ m .Set (cm .StrKey ("key" ), 10 )
47
+ t .Log (m .Get (cm .StrKey ("key" )))
48
+ }
49
+
50
+ //运行结果
51
+ //=== RUN TestConcurrentMap
52
+ //--- PASS: TestConcurrentMap (0.00s)
53
+ //get_remote_pack_test.go:48: 10 true
54
+ //PASS
Original file line number Diff line number Diff line change
1
+ package : go-19/module_package/get_remote_pack_test.go
2
+ import : []
3
+ testImport :
4
+ - package : github.com/easierway/concurrent_map
5
+ version : ^1.0.0
You can’t perform that action at this time.
0 commit comments