Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

golang "go get comand" how this works?

Tags:

go

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

like image 304
vrbilgi Avatar asked Dec 07 '14 13:12

vrbilgi


People also ask

How does go get command work?

In Go, you can use the get command to download and install packages and dependencies. Azure Repos Git provides support for go get within an Azure Repos Git repository. With go get , you will be able to download packages with their dependencies named by the import paths.

What happens when go get?

Generally speaking, when you run a go get command, Go downloads the package to your computer if it is not present in your local cache.

How do you use Go get?

Simply click the Join button anywhere on our site to register. Once you've been approved, you'll pick up a GoGet smart card or we'll mail you one. Once your smart card is activated you can start booking cars on GoGet's iPhone or Android app.

Why is go get deprecated?

Why this is happening. Since modules were introduced, the go get command has been used both to update dependencies in go. mod and to install commands. This combination is frequently confusing and inconvenient: in most cases, developers want to update a dependency or install a command but not both at the same time.


1 Answers

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.

like image 113
VonC Avatar answered Oct 04 '22 18:10

VonC