go/src/cmd/go/internal/modindex/read.go

var enabled

type Module

// moduleHash returns an ActionID corresponding to the state of the module
// located at filesystem path modroot.
func moduleHash(modroot string, ismodcache bool) (cache.ActionID, error) {}

const modTimeCutoff

// dirHash returns an ActionID corresponding to the state of the package
// located at filesystem path pkgdir.
func dirHash(modroot, pkgdir string) (cache.ActionID, error) {}

var ErrNotIndexed

var errDisabled

var errNotFromModuleCache

// GetPackage returns the IndexPackage for the directory at the given path.
// It will return ErrNotIndexed if the directory should be read without
// using the index, for instance because the index is disabled, or the package
// is not in a module.
func GetPackage(modroot, pkgdir string) (*IndexPackage, error) {}

// GetModule returns the Module for the given modroot.
// It will return ErrNotIndexed if the directory should be read without
// using the index, for instance because the index is disabled, or the package
// is not in a module.
func GetModule(modroot string) (*Module, error) {}

var mcache

// openIndexModule returns the module index for modPath.
// It will return ErrNotIndexed if the module can not be read
// using the index because it contains symlinks.
func openIndexModule(modroot string, ismodcache bool) (*Module, error) {}

var pcache

func openIndexPackage(modroot, pkgdir string) (*IndexPackage, error) {}

var errCorrupt

// protect marks the start of a large section of code that accesses the index.
// It should be used as:
//
//	defer unprotect(protect, &err)
//
// It should not be used for trivial accesses which would be
// dwarfed by the overhead of the defer.
func protect() bool {}

var isTest

// unprotect marks the end of a large section of code that accesses the index.
// It should be used as:
//
//	defer unprotect(protect, &err)
//
// end looks for panics due to errCorrupt or bad mmap accesses.
// When it finds them, it adds explanatory text, consumes the panic, and sets *errp instead.
// If errp is nil, end adds the explanatory text but then calls base.Fatalf.
func unprotect(old bool, errp *error) {}

// fromBytes returns a *Module given the encoded representation.
func fromBytes(moddir string, data []byte) (m *Module, err error) {}

// packageFromBytes returns a *IndexPackage given the encoded representation.
func packageFromBytes(modroot string, data []byte) (p *IndexPackage, err error) {}

// pkgDir returns the dir string of the i'th package in the index.
func (m *Module) pkgDir(i int) string {}

// pkgOff returns the offset of the data for the i'th package in the index.
func (m *Module) pkgOff(i int) int {}

// Walk calls f for each package in the index, passing the path to that package relative to the module root.
func (m *Module) Walk(f func(path string)) {}

// relPath returns the path relative to the module's root.
func relPath(path, modroot string) string {}

var installgorootAll

// Import is the equivalent of build.Import given the information in Module.
func (rp *IndexPackage) Import(bctxt build.Context, mode build.ImportMode) (p *build.Package, err error) {}

// IsStandardPackage reports whether path is a standard package
// for the goroot and compiler using the module index if possible,
// and otherwise falling back to internal/goroot.IsStandardPackage
func IsStandardPackage(goroot_, compiler, path string) bool {}

// IsDirWithGoFiles is the equivalent of fsys.IsDirWithGoFiles using the information in the index.
func (rp *IndexPackage) IsDirWithGoFiles() (_ bool, err error) {}

// ScanDir implements imports.ScanDir using the information in the index.
func (rp *IndexPackage) ScanDir(tags map[string]bool) (sortedImports []string, sortedTestImports []string, err error) {}

func keys(m map[string]bool) []string {}

// implements imports.ShouldBuild in terms of an index sourcefile.
func shouldBuild(sf *sourceFile, tags map[string]bool) bool {}

type IndexPackage

var errCannotFindPackage

// Package and returns finds the package with the given path (relative to the module root).
// If the package does not exist, Package returns an IndexPackage that will return an
// appropriate error from its methods.
func (m *Module) Package(path string) *IndexPackage {}

// pkg returns the i'th IndexPackage in m.
func (m *Module) pkg(i int) *IndexPackage {}

type sourceFile

const sourceFileError

const sourceFileParseError

const sourceFileSynopsis

const sourceFileName

const sourceFilePkgName

const sourceFileIgnoreFile

const sourceFileBinaryOnly

const sourceFileCgoDirectives

const sourceFileGoBuildConstraint

const sourceFileNumPlusBuildConstraints

func (sf *sourceFile) error() string {}

func (sf *sourceFile) parseError() string {}

func (sf *sourceFile) synopsis() string {}

func (sf *sourceFile) name() string {}

func (sf *sourceFile) pkgName() string {}

func (sf *sourceFile) ignoreFile() bool {}

func (sf *sourceFile) binaryOnly() bool {}

func (sf *sourceFile) cgoDirectives() string {}

func (sf *sourceFile) goBuildConstraint() string {}

func (sf *sourceFile) plusBuildConstraints() []string {}

func (sf *sourceFile) importsOffset() int {}

func (sf *sourceFile) embedsOffset() int {}

func (sf *sourceFile) directivesOffset() int {}

func (sf *sourceFile) imports() []rawImport {}

func (sf *sourceFile) embeds() []embed {}

func (sf *sourceFile) directives() []build.Directive {}

func asString(b []byte) string {}

type decoder

// intAt returns the int at the given offset in d.data.
func (d *decoder) intAt(off int) int {}

// boolAt returns the bool at the given offset in d.data.
func (d *decoder) boolAt(off int) bool {}

// stringAt returns the string pointed at by the int at the given offset in d.data.
func (d *decoder) stringAt(off int) string {}

// stringTableAt returns the string at the given offset in the string table d.str.
func (d *decoder) stringTableAt(off int) string {}

type reader

// readAt returns a reader starting at the given position in d.
func (d *decoder) readAt(pos int) *reader {}

// int reads the next int.
func (r *reader) int() int {}

// string reads the next string.
func (r *reader) string() string {}

// bool reads the next bool.
func (r *reader) bool() bool {}

// tokpos reads the next token.Position.
func (r *reader) tokpos() token.Position {}