2020年9月11日 星期五

[ 常見問題 ] Go Mod Private Repo

Source From Here
Question
So I have a private repo that my main.go imports. I'm getting this error when I do a go build:
cannot find module for path

Do I need to do anything special for a private repo? I have been googling and can't find any good information. It works fine with dep.

How-To
Do this
# git config --global --add url."git@your-repo.com:".insteadOf "https://your-repo.com/"
# export GOPRIVATE='your-repo.com'

Make sure your git clone via ssh works.

Supplement
* Medium - Fetching Private Dependencies with Go Modules
Since Go modules currently has no ability to recognize that a dependency fetched from, for example, https://github.com/ can also be fetched from ssh://git@github.com/ , we need to configure git to perform that substitution for us. The quickest way to do this is git config --global url."ssh://git@github.com/".insteadOf "https://github.com/" . This will create a file at $HOME/.gitconfig (or modify an existing one). If you’d like this to apply to all users, substitute --global with --system .


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...