如何使用go get私有github企业服务器?

时间:2018-01-24 03:01:23

标签: go github-enterprise

我们通过VPN使用github企业服务器。

如果我输入:

go get privateserver.com/path/to/myproject.git

我得到了这个结果:

package privateserver.com/path/to/myproject.git: cannot download, privateserver.com/path/to/myproject uses insecure protocol

或者删除我得到的.git后缀:

package privateserver.com/path/to/myproject: unrecognized import path "privateserver.com/path/to/myproject" (parse https://privateserver.com/path/to/myproject?go-get=1: no go-import meta tags ())

谷歌搜索似乎有很多类似的问题,但没有找到实际有用的答案。

我真正想要的是Docker构建的自动化。 在我的docker文件中,我需要一个go get。但是我无法将凭证存储在docker文件中。

注意: - 安全无效。见问题的底部。

刚尝试过-insecure -v选项。 我得到以下输出:

matthewh@xen:~/go/src/$ go get -insecure -v privateserver.com/path/to/myproject.git
# cd .; git ls-remote git://privateserver.com/path/to/myproject
fatal: remote error: 
  GitHub private mode is enabled. Git protocol is disabled. Use authenticated http or ssh access instead.
# cd .; git ls-remote https://privateserver.com/path/to/myproject
fatal: could not read Username for 'https://privateserver.com': terminal prompts disabled
# cd .; git ls-remote http://privateserver.com/path/to/myproject
fatal: could not read Username for 'https://privateserver.com': terminal prompts disabled
# cd .; git ls-remote git+ssh://privateserver.com/path/to/myproject
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
# cd .; git ls-remote ssh://privateserver.com/path/to/myproject
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
privateserver.com/path/to/myproject.git (download)
# cd .; git clone privateserver.com/path/to/myproject /home/matthewh/go/src/privateserver.com/path/to/myproject.git
fatal: repository 'privateserver.com/path/to/myproject' does not exist
package privateserver.com/path/to/myproject.git: exit status 128

1 个答案:

答案 0 :(得分:1)

get命令支持使用-insecure标志使用http,如下所示:

go get -insecure privateserver.com/path/to/myproject.git

默认为安全HTTPS,以防止人员处于中间攻击,如Git Issue中所述。