golang "go get comand" how this works?

huangapple go评论72阅读模式
英文:

golang "go get comand" how this works?

问题

最初我以为它的工作方式类似于Java的Maven,它有自己的仓库并下载依赖项,但是Go的git似乎与Git Bazaar这样的版本控制系统有依赖关系。

当我运行以下命令时:

go get launchpad.net/mgo

我得到以下错误信息:

go: missing Bazaar command. See http://golang.org/s/gogetcmd
package launchpad.net/mgo: exec: "bzr": 可执行文件未在$PATH中找到

编辑:
我的主要问题是当我运行以下命令时:

go get gopkg.in/mgo.v2

我得到以下错误信息:

fatal: unable to access 'https://gopkg.in/mgo.v2/': SSL certificate problem: self signed certificate in certificate chain
package gopkg.in/mgo.v2: exit status 128

这是因为Git需要证书。我可以使用以下命令克隆该仓库:

git -c http.sslVerify=false clone

我需要在某个地方进行类似的设置,以便通过go get命令获取它。

英文:

Initially I thought it works as like java maven
where it has its own repository and downloads dependencies

but go git seems to have dependency with git Bazaar like version control system.

go get launchpad.net/mgo 
go: missing Bazaar command. See http://golang.org/s/gogetcmd
package launchpad.net/mgo: exec: "bzr": executable file not found in $PATH

Edit:
My main problem is when i do

go get gopkg.in/mgo.v2 I get

fatal: unable to access 'https://gopkg.in/mgo.v2/': SSL certificate problem: self signed certificate in certificate chain
package gopkg.in/mgo.v2: exit status 128

This is because of git needs certificate. I am able to clone this repo using
git -c http.sslVerify=false clone

I have to do the similar setting some where to get it from go get command

答案1

得分: 4

我的主要问题是当我执行以下操作时:

go get gopkg.in/mgo.v2

fatal: unable to access 'https://gopkg.in/mgo.v2/': 
SSL certificate problem: self signed certificate in certificate chain
package gopkg.in/mgo.v2: exit status 128

如果底层仓库是一个Git仓库(在这里似乎是这样:github.com/go-mgo/mgo/tree/v2),那么你可以通过以下方式临时禁用SSL来解决:

git config --global http.sslVerify false

初始答案:

go remote import path中所述,一些预定义的导入路径需要一些关联的版本控制工具:

Launchpad(Bazaar)

import "launchpad.net/project"

Go可以从任何你想要的仓库获取,但是,如“在使用私有git仓库时的go工作区结构”中所解释的那样:

导入路径可以使用版本控制类型进行限定,或者go工具可以通过https/http动态获取导入路径,并从HTML中的标签中发现代码所在的位置。

在这里,导入路径足以让go推断出它需要什么工具。

英文:

My main problem is when I do:

go get gopkg.in/mgo.v2

fatal: unable to access 'https://gopkg.in/mgo.v2/': 
SSL certificate problem: self signed certificate in certificate chain
package gopkg.in/mgo.v2: exit status 128

If the underlying repo is a Git repo (which seems to be the case here: github.com/go-mgo/mgo/tree/v2), then you can deactivate ssl (temporarily) with:

git config --global http.sslVerify false

Initial answer:

As mentioned in go remote import path, some pre-defined import path will require some associated version control tool to be present:

Launchpad (Bazaar)

import "launchpad.net/project"

Go can get from any repo you want, but, as explained in "Structure for your go workspace when using private git repository"

> import paths may either be qualified with the version control type, or the go tool can dynamically fetch the import path over https/http and discover where the code resides from a tag in the HTML.

Here, the import path is enough for go to infer what tool it needs.

huangapple
  • 本文由 发表于 2014年12月7日 21:48:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/27343299.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定