Description
The go
command automatically fetches modules from network hosts, provided that those modules have a path whose first element includes a dot character (.
).
First-elements that do not include a dot are, in general, reserved for the standard library and the Go toolchain (see #32819). Some names (std
, cmd
, all
) have a special meaning no matter where they are used. Others (such as archive
and debug
) are currently standard-library prefixes but not packages, but could be made so in the future (as was done in the case of encoding
).
Still others currently have no meaning, but may be assigned a special meaning in the future: for example, I would like to add mod
to refer to the main module independent of its path (that would be a separate proposal).
The fact that import paths are required to contain a dot occasionally causes user consternation (#37554, #34592).
I propose that we explicitly reserve the following package paths for user code:
- for general use:
local
- But not
localhost
, which we may at some point want to treat as a hostname.
- But not
- for documentation, tutorials, and bug reports:
example
(along the lines ofexample.com
, because it looks more like “something you should replace” thanlocal
does)
- for tests, especially tests of tools that manipulate modules (and thus need a “clean” module to run in):
test
, which we already sort-of use:Line 1 in b1a783d
- for module-graph and package-import-graph examples:
main
(because it is useful to indicate "the main module", and apackage main
is not importable anyway), and- any valid module path that consists of a single letter, because we already use those a lot in
cmd/go
tests.
CC @bronze1man @DisposaBoy @mvdan @jayconrod @matloob @thepudds