Documentation
¶
Overview ¶
Package modindex contains code for building and searching an Index of the Go module cache.
Index ¶
Constants ¶
const CurrentVersion int = 0
CurrentVersion tells readers about the format of the index.
Variables ¶
var IndexDir string = func() string { var dir string if testing.Testing() { dir = os.TempDir() } else { var err error dir, err = os.UserCacheDir() if err != nil { dir = os.TempDir() } } dir = filepath.Join(dir, "goimports") if err := os.MkdirAll(dir, 0777); err != nil { log.Printf("failed to create modcache index dir: %v", err) } return dir }()
IndexDir is where the module index is stored. Each logical index entry consists of a pair of files:
- the "payload" (index-VERSION-XXX), whose name is randomized, holds the actual index; and
- the "link" (index-name-VERSION-HASH), whose name is predictable, contains the name of the payload file.
Since the link file is small (<512B), reads and writes to it may be assumed atomic.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct { Dir string // package directory relative to GOMODCACHE; uses OS path separator ImportPath string PkgName string Version string Names []string // exported names and information }
An Entry contains information for an import path.
type Index ¶
type Index struct { Version int GOMODCACHE string // absolute path of Go module cache dir ValidAt time.Time // moment at which the index was up to date Entries []Entry }
Index is returned by Read.
func Read ¶ added in v0.36.0
Read reads the latest version of the on-disk index for the specified Go module cache directory. If there is no index, it returns a nil Index and an fs.ErrNotExist error.
func Update ¶ added in v0.27.0
Update updates the index for the specified Go module cache directory, creating it as needed. On success it returns the current index.
func (*Index) Lookup ¶ added in v0.27.0
Lookup finds all the symbols in the index with the given PkgName and name. If prefix is true, it finds all of these with name as a prefix.
Directories
¶
Path | Synopsis |
---|---|
A command for building and maintaining the module cache a.out <flags> <command> <args> The commands are: 'update', which attempts to update an existing index, 'query', which looks up things in the index.
|
A command for building and maintaining the module cache a.out <flags> <command> <args> The commands are: 'update', which attempts to update an existing index, 'query', which looks up things in the index. |