Mar 8, 2019

[Go] special directory recognized by go cmd


  • internal
    https://golang.org/doc/go1.4#internalpackages
    Place source files in a directory named internal or in a sub-directory of a directory named internal.
    When the go command sees an import of a package with internal in its path, it verifies that the package doing the import is within the tree rooted at the parent of the internal directory.
    e.g:
    a package .../a/b/c/internal/d/e/f can be imported only by code in the directory tree rooted at .../a/b/c.
    It cannot be imported by code in .../a/b/g or in any other repository.
  • testdata
    Go tool ignores directory named "testdata", making it available to hold ancillary data needed by the tests.
  • vendor
    When the main module contains a top-level vendor directory and its go.mod file specifies go 1.14 or higher, the go command now defaults to -mod=vendor
    When -mod=vendor is set (explicitly or by default), the go command now verifies that the main module's vendor/modules.txt file is consistent with its go.mod file.
    By default, the go command satisfies dependencies by downloading modules from their sources and using those downloaded copies (after verification).

    Note that only the main module's top-level vendor directory is used; vendor directories in other locations are still ignored.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.