go get module 私有仓库

最近想写点go 的东西,但是又不想public,于是设置成了private,但是在go get 的时候,发现go默认是走git clone https://github.com/xxx/xxxx这样,go没有给你输入账号密码的机会所以就会报下面这个错误

$go get github.com/xxxxx/xxxx

go: downloading github.com/xxxx

go get: github.com/xxxx: verifying module: github.com/xxxx: reading https://sum.golang.org/lookup/github.com/!xxxx/!xxxx: 410 Gone

server response:

not found: github.com/xxxx: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/8731ec5feb87aab92abb46a929c4243f90e5f75d15c1c476e66775283a70cec2: exit status 128:

fatal: could not read Username for 'https://github.com': terminal prompts disabled

咋解决呢?
在用户目录下建立这么一个文件

touch ~/.netrc //其实不用touch,写出来只是说明
echo "machine 写你的github地址: github.com/xxxx login xxxxxx password xxxxx" > ~/.netrc

然后在go get moudle就可以成功拉取了,百度对于这个写的支支吾吾的不清楚,写下用来记录

2 个赞

服务器资源由ZeptoVM赞助

Partners Wiki Discord