go/src/cmd/go/internal/modfetch/coderepo.go

type codeRepo

// newCodeRepo returns a Repo that reads the source code for the module with the
// given path, from the repo stored in code, with the root of the repo
// containing the path given by codeRoot.
func newCodeRepo(code codehost.Repo, codeRoot, path string) (Repo, error) {}

func (r *codeRepo) ModulePath() string {}

func (r *codeRepo) CheckReuse(ctx context.Context, old *codehost.Origin) error {}

func (r *codeRepo) Versions(ctx context.Context, prefix string) (*Versions, error) {}

// appendIncompatibleVersions appends "+incompatible" versions to list if
// appropriate, returning the final list.
//
// The incompatible list contains candidate versions without the '+incompatible'
// prefix.
//
// Both list and incompatible must be sorted in semantic order.
func (r *codeRepo) appendIncompatibleVersions(ctx context.Context, origin *codehost.Origin, list, incompatible []string) (*Versions, error) {}

func (r *codeRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) {}

func (r *codeRepo) Latest(ctx context.Context) (*RevInfo, error) {}

// convert converts a version as reported by the code host to a version as
// interpreted by the module system.
//
// If statVers is a valid module version, it is used for the Version field.
// Otherwise, the Version is derived from the passed-in info and recent tags.
func (r *codeRepo) convert(ctx context.Context, info *codehost.RevInfo, statVers string) (revInfo *RevInfo, err error) {}

// validatePseudoVersion checks that version has a major version compatible with
// r.modPath and encodes a base version and commit metadata that agrees with
// info.
//
// Note that verifying a nontrivial base version in particular may be somewhat
// expensive: in order to do so, r.code.DescendsFrom will need to fetch at least
// enough of the commit history to find a path between version and its base.
// Fortunately, many pseudo-versions — such as those for untagged repositories —
// have trivial bases!
func (r *codeRepo) validatePseudoVersion(ctx context.Context, info *codehost.RevInfo, version string) (err error) {}

func (r *codeRepo) revToRev(rev string) string {}

func (r *codeRepo) versionToRev(version string) (rev string, err error) {}

// findDir locates the directory within the repo containing the module.
//
// If r.pathMajor is non-empty, this can be either r.codeDir or — if a go.mod
// file exists — r.codeDir/r.pathMajor[1:].
func (r *codeRepo) findDir(ctx context.Context, version string) (rev, dir string, gomod []byte, err error) {}

// isMajor reports whether the versions allowed for mpath are compatible with
// the major version(s) implied by pathMajor, or false if mpath has an invalid
// version suffix.
func isMajor(mpath, pathMajor string) bool {}

// canReplaceMismatchedVersionDueToBug reports whether versions of r
// could replace versions of mpath with otherwise-mismatched major versions
// due to a historical bug in the Go command (golang.org/issue/34254).
func (r *codeRepo) canReplaceMismatchedVersionDueToBug(mpath string) bool {}

func (r *codeRepo) GoMod(ctx context.Context, version string) (data []byte, err error) {}

// LegacyGoMod generates a fake go.mod file for a module that doesn't have one.
// The go.mod file contains a module directive and nothing else: no go version,
// no requirements.
//
// We used to try to build a go.mod reflecting pre-existing
// package management metadata files, but the conversion
// was inherently imperfect (because those files don't have
// exactly the same semantics as go.mod) and, when done
// for dependencies in the middle of a build, impossible to
// correct. So we stopped.
func LegacyGoMod(modPath string) []byte {}

func (r *codeRepo) modPrefix(rev string) string {}

func (r *codeRepo) retractedVersions(ctx context.Context) (func(string) bool, error) {}

func (r *codeRepo) Zip(ctx context.Context, dst io.Writer, version string) error {}

type zipFile

func (f zipFile) Path() string                 {}

func (f zipFile) Lstat() (fs.FileInfo, error)  {}

func (f zipFile) Open() (io.ReadCloser, error) {}

type dataFile

func (f dataFile) Path() string                {}

func (f dataFile) Lstat() (fs.FileInfo, error) {}

func (f dataFile) Open() (io.ReadCloser, error) {}

type dataFileInfo

func (fi dataFileInfo) Name() string       {}

func (fi dataFileInfo) Size() int64        {}

func (fi dataFileInfo) Mode() fs.FileMode  {}

func (fi dataFileInfo) ModTime() time.Time {}

func (fi dataFileInfo) IsDir() bool        {}

func (fi dataFileInfo) Sys() any           {}

func (fi dataFileInfo) String() string {}

// hasPathPrefix reports whether the path s begins with the
// elements in prefix.
func hasPathPrefix(s, prefix string) bool {}