Golang module path: Difference between revisions

From wikinotes
No edit summary
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 3: Line 3:
but the actual src is hosted using a server/service of your choosing.
but the actual src is hosted using a server/service of your choosing.


= URL suffix =
= Documentation =
<blockquote>
{| class="wikitable"
|-
| official docs: vcs-find || https://go.dev/ref/mod#vcs-find
|-
|}
</blockquote><!-- Documentation -->
 
= Notes =
<blockquote>
== URL suffix ==
<blockquote>
<blockquote>
Suffix indicating repository type
Suffix indicating repository type
Line 22: Line 33:
</blockquote><!-- url suffix -->
</blockquote><!-- url suffix -->


= HTTP meta tag =
== HTTP meta tag ==
<blockquote>
<blockquote>
HTTP meta tag
HTTP meta tag
Line 30: Line 41:
   You may use a import-prefix that has nothing to do with your URL.
   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"
   IMPORT-PREFIX: the name of the package being fetched (ex. example.com/x/foo)"
   VCS:          bzr, fossil, git, hg, svn
   VCS:          bzr, fossil, git, hg, svn
   REPO-ROOT:    URL to repo-root (no VCS extension!)
   REPO-ROOT:    URL to repo-root (no VCS extension!)
-->
-->
<!--                            IMPORT-PREFIX VCS  REPO-ROOT                -->
<!--                            IMPORT-PREFIX       VCS  REPO-ROOT                -->
<meta name="go-import" content="example.org    git  https://code.org/r/p/exproj">
<meta name="go-import" content="example.org/x/foo   git  git+ssh://repos.org:/repos/foo">
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- HTTP meta tag -->
</blockquote><!-- HTTP meta tag -->


= Hosted services =
== Hosted services ==
<blockquote>
<blockquote>
Hosted Services
Hosted Services
Line 56: Line 67:
</blockquote><!-- Hosted services -->
</blockquote><!-- Hosted services -->


= Private modules =
== Private modules ==
<blockquote>
<blockquote>
{{ 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.
You may use private modules, but you'll need to set environment variables to keep them private.


Line 71: Line 80:
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Private modules -->
</blockquote><!-- Private modules -->
</blockquote><!-- Notes -->
= Sample Configurations =
<blockquote>
{| class="wikitable"
|-
| [[golang private modules conf: meta tags, git+ssh, nginx]]
|-
|}
</blockquote><!-- Sample Configurations -->

Latest revision as of 00:24, 21 July 2022

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.

Documentation

official docs: vcs-find https://go.dev/ref/mod#vcs-find

Notes

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: the name of the package being fetched (ex. example.com/x/foo)"
  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/x/foo    git   git+ssh://repos.org:/repos/foo">

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

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

Sample Configurations

golang private modules conf: meta tags, git+ssh, nginx