Golang module path

From wikinotes
Revision as of 14:10, 19 June 2022 by Will (talk | contribs) (Created page with "Module paths are used both to locate, and uniquely identify packages.<br> Downloading packages is normally performed by a lookup in go index,<br> but the actual src is hosted using a server/service of your choosing. === URL suffix === <blockquote> Suffix indicating repository type <syntaxhighlight lang="go"> # Repos supporting multiple protocols will try each in order. # ex: https://, git://, git+ssh:// # # # Bazaar .bzr # Fossil .fossil # Git .git # M...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Module paths are used both to locate, and uniquely identify packages.
Downloading packages is normally performed by a lookup in go index,
but the actual src is hosted using a server/service of your choosing.

URL suffix

Suffix indicating repository type

# Repos supporting multiple protocols will try each in order.
# ex: https://, git://, git+ssh://
#
#
# Bazaar      .bzr
# Fossil      .fossil
# Git         .git
# Mercurial   .hg
# Subversion  .svn

import "example.com/path/to/repo.git"
import "example.com/path/to/repo.git/sub/directory"

HTTP meta tag

HTTP meta tag

<!--
  Meta tags let you abstract the path of your src.
  You may use a import-prefix that has nothing to do with your URL.

  IMPORT-PREFIX: prefix of unique-identifier of package (not necessarily url) ex. "foo.com/x"
  VCS:           bzr, fossil, git, hg, svn
  REPO-ROOT:     URL to repo-root (no VCS extension!)
-->
<!--                            IMPORT-PREFIX  VCS   REPO-ROOT                 -->
<meta name="go-import" content="example.org    git   https://code.org/r/p/exproj">

Hosted services

Hosted Services

# github.com
import "github.com/user/your_project"
import "github.com/user/your_project/sub/directory"

# launchpad.net
import "launchpad.net/project"
import "launchpad.net/project/series"
import "launchpad.net/project/series/sub/directory"

# ...

Private modules

TODO:

verify you can host your own proxy/checksums

You may use private modules, but you'll need to set environment variables to keep them private.

# ignore checksum checks on these packages
GOPRIVATE=*.corp.example.com,rsc.io/private

# alternatively, define your own proxy with your own checksums
GOPROXY=proxy.example.com
GONOPROXY=none