Skip to content

Instantly share code, notes, and snippets.

@Akagi201
Last active December 17, 2018 02:26
Show Gist options
  • Save Akagi201/736dc0cbbec6b9a9af164a5242efa17c to your computer and use it in GitHub Desktop.
Save Akagi201/736dc0cbbec6b9a9af164a5242efa17c to your computer and use it in GitHub Desktop.
[go-dep]

项目依赖版本管理

解决��依赖管理工具访问私用厂库(gitlab自荐私有厂库)的方法

方法1. 通过https方法:https://golang.github.io/dep/docs/FAQ.html (CI部署)

方法2. 通过ssh方法:假定你已经上传本地ssh公钥,并保存到gitlab账户管理里面。(推荐)

$ git config --global url."ssh://[email protected]:2222/".insteadOf "https://git.5th.im/"

$ cat ~/.gitconfig

# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
        name = suyanlong
        email = [email protected]
[url "ssh://[email protected]:2222/"]
        insteadOf = https://git.5th.im/

使用go1.11以上版本,推荐使用golang最新版本1.11.2,使用go mod机制。

使用dep管理工具。

使用glide 版本管理工具。

修改厂库��名字,符合golang ��路径项目管理规范,或者修改import导入规范。(推荐)

在不修改任何的情况下管理go项目依赖,�只能使用gilde(�非常,非常,非常不推荐!!!)

$ glide --version
glide version 0.13.2

在项目root目录下下运行:glide init 命令,生成glide.yaml文件,修改自己公司引用的依赖�package并修改ssh� git clone方式。glide.yaml内容片断例如:

...
- package: github.com/5thwork/rpc-protos
  subpackages:
  - shiralee
...

修改如下:

...
- package: github.com/5thwork/rpc-protos
  repo:    ssh://[email protected]:2222/core-team/rpc-protos.git
  vcs:     git
  subpackages:
  - shiralee
...

管理自己的依赖,上传vendor目录,以及glide.lock,glide.yaml文件,锁定依赖package的版本,��并定时更新vendor。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment