GO-REMOTE(7)
GO-REMOTE(7) π Miscellaneous Information Manual π
β¨ NAME β¨
okay so this one is about go, the tool for managing Go source code π
β¨ DESCRIPTION β¨
okay bestie, so an import path (see go-importpath(1)) is basically how you name a package that lives in your local file system π some import paths also tell the go tool where to grab the source code from a version control system, and that part is lowkey so iconic π¦
a few popular code hosting sites have their own special syntax, so you don't have to do extra work π«Ά
BitBucket (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"
okay, for code living on other servers π your import paths can either be qualified with the version control type, or the go tool can dynamically fetch the import path over https/http and figure out where the code is hiding from a <meta> tag in the HTML β¨
to declare the code location yourself, use an import path of this form:
repository.vcs/path
this points at the given repository, with or without the .vcs suffix, using the named version control system, and then the path inside that repository πΈ the supported version control systems are:
- Bazaar β
.bzr - Git β
.git - Mercurial β
.hg - Subversion β
.svn
for example,
import "example.org/user/foo.hg"
gives you the root directory of the Mercurial repository at example.org/user/foo or foo.hg, and
import "example.org/repo.git/foo/bar"
gives you the foo/bar directory of the Git repository at example.com/repo or repo.git π§
when a version control system supports multiple protocols, each one gets tried in turn when downloading. for example, a Git download triesgit://, thenhttps://, thenhttp://. π
if the import path isn't a known code hosting site and also doesn't have a version control qualifier, the go tool tries to fetch the import over https/http and looks for a <meta> tag in the document's HTML <head> π
the meta tag looks like this:
<meta name="go-import" content="import-prefix vcs repo-root">
the import-prefix is the import path that matches the repository root. it has to be a prefix or an exact match of the package being fetched with go get. if it's not an exact match, another http request gets made at the prefix to double check the <meta> tags match π
the vcs is one of "git", "hg", "svn", etc,
the repo-root is the root of the version control system, containing a scheme and not containing a .vcs qualifier π
for example,
import "example.org/pkg/foo"
will result in the following request(s):
https://example.org/pkg/foo?go-get=1 (preferred)
http://example.org/pkg/foo?go-get=1 (fallback)
if that page contains the meta tag
<meta name="go-import" content="example.org git https://code.org/r/p/exproj">
the go tool will verify that https://example.org/?go-get=1 contains the same meta tag, and then run git clone https://code.org/r/p/exproj into GOPATH/src/example.org π
newly downloaded packages get written to the first directory listed in the GOPATH environment variable (see go-path(1)) π¦
the go command tries to download the version of the package that matches the Go release you're using. see go-install(1) for more π
β¨ AUTHOR β¨
this manual page was written by Michael Stapelberg <stapelberg@debian.org>, for the Debian project (and may be used by others) π«Ά
bestie, that's the whole thing β¨ this page was dated 2012-05-13 and it's GO-REMOTE(7), so you're officially up to date ππΈ
π¦ where this page comes from
- debian bookworm: gccgo-go 2:1.19~1 Β· Go
- debian bookworm: golang-go 2:1.19~1 Β· Go
- debian trixie: gccgo-go 2:1.24~2 Β· Go
- debian trixie: golang-go 2:1.24~2 Β· Go
- ubuntu jammy: gccgo-go 2:1.18~0ubuntu2 Β· Go
- ubuntu jammy: golang-go 2:1.18~0ubuntu2 Β· Go
- ubuntu noble: gccgo-go 2:1.22~2build1 Β· Go
- ubuntu noble: golang-go 2:1.22~2build1 Β· Go
- ubuntu questing: gccgo-go 2:1.24~2
- ubuntu questing: golang-go 2:1.24~2 Β· Go
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms