Reputation: 150614
In Go, there is the practice that if you create a project that is stored on GitHub, to use a folder name that is:
./src/github.com/<user>/<repo>
When I now run go get
, Go knows how to check out the repo.
Now I wonder if there is some special support baked in into Go for GitHub (and if so, for what else is this available), or if this works with any URL (and if so, what has to be placed on that URL to make things work).
Can anybody please shed some light onto this?
Upvotes: 2
Views: 164
Reputation: 2809
Yes, go tool has support for the most popular code hosting sites out of the box:
Bitbucket (Git, Mercurial)
import "bitbucket.org/user/project"
import "bitbucket.org/user/project/sub/directory"
GitHub (Git)
import "github.com/user/project"
import "github.com/user/project/sub/directory"
Google Code Project Hosting (Git, Mercurial, Subversion)
import "code.google.com/p/project"
import "code.google.com/p/project/sub/directory"
import "code.google.com/p/project.subrepository"
import "code.google.com/p/project.subrepository/sub/directory"
Launchpad (Bazaar)
import "launchpad.net/project"
import "launchpad.net/project/series"
import "launchpad.net/project/series/sub/directory"
import "launchpad.net/~user/project/branch"
import "launchpad.net/~user/project/branch/sub/directory"
For the unknown sites you have two options - specify VCS type directly in the import path:
import "example.org/user/foo.git"
or prepare your repo to include tag in HTML, like this:
<meta name="go-import" content="example.org git https://code.org/r/p/exproj">
See go docs for more details, it's thoroughly explained (also available by go help importpath, as stated in comments):
http://golang.org/cmd/go/#hdr-Remote_import_paths
Upvotes: 6