Modules和Vendor
-
Vendorgit
- 使用的时候,代码依旧要放在go path路径下
- 每一个项目都要有一个vendor项目,而后下载到项目下的此目录,重复率很高
-
modulesgithub
- 能够放在任何目录,配置好代理,下载方便,都在一个仓库文件,不用重复下载
modules怎么面对,非正规的路径
- 以bytom来讲,可能由于某些缘由,致使path路径和代码中包使用路径不一致
- 代码中import的路径:github.com/vapor
- github上的代码路径:github.com/Bytom/vapor
若是我想使用这个代码中的函数,怎么引用呢?
使用replace为导入的包指定下载的路径
replace github.com/vapor v0.1.0 => github.com/Bytom/vapor v0.1.0
在go.mod文件中添加这一行代码,那么就能够在你的代码中随意使用了函数
import (
"github.com/vapor/common"
"github.com/vapor/consensus"
"github.com/vapor/consensus/segwit"
)
遇到这样的问题,还有什么方式解决呢?
- 能够在GitHub上提issue(固然因为项目很大,可能没法修改,即便你们都知道这个问题)
- 使用vendor