package modload
import "cuelang.org/go/internal/mod/modload"
Index ¶
- func CheckTidy(ctx context.Context, fsys fs.FS, modRoot string, reg Registry) error
- func LatestVersion(versions []string) string
- func ResolveAbsolutePackage(ctx context.Context, reg Registry, p string) (module.Version, module.SourceLoc, error)
- func Tidy(ctx context.Context, fsys fs.FS, modRoot string, reg Registry) (*modfile.File, error)
- func UpdateVersions(ctx context.Context, fsys fs.FS, modRoot string, reg Registry, versions []string) (*modfile.File, error)
- type ErrModuleNotTidy
- type Registry
Functions ¶
func CheckTidy ¶
CheckTidy checks that the module file in the given main module is considered tidy. A module file is considered tidy when: - it can be parsed OK by modfile.ParseStrict. - it contains a language version in canonical semver form - it includes valid modules for all of its dependencies - it does not include any unnecessary dependencies.
func LatestVersion ¶
LatestVersion returns the latest of any of the given versions, ignoring prerelease versions if there is any stable version.
func ResolveAbsolutePackage ¶
func ResolveAbsolutePackage(ctx context.Context, reg Registry, p string) (module.Version, module.SourceLoc, error)
ResolveAbsolutePackage resolves a package in a standalone fashion, irrespective of a module file. It returns the module containing that package and the location of the package.
It tries to avoid hitting the network unless necessary by using cached results where available.
func Tidy ¶
Tidy evaluates all the requirements of the given main module, using the given registry to download requirements and returns a resolved and tidied module file.
func UpdateVersions ¶
func UpdateVersions(ctx context.Context, fsys fs.FS, modRoot string, reg Registry, versions []string) (*modfile.File, error)
UpdateVersions returns the main module's module file with the specified module versions updated if possible and added if not already present. It returns an error if asked to downgrade a module below a version already required by an external dependency.
A module in the versions slice can be specified as one of the following:
- $module@$fullVersion: a specific exact version
- $module@$partialVersion: a non-canonical version specifies the latest version that has the same major/minor numbers.
- $module@latest: the latest non-prerelease version, or latest prerelease version if there is no non-prerelease version
- $module: equivalent to $module@latest if $module doesn't have a default major version or $module@$majorVersion if it does, where $majorVersion is the default major version for $module.
Types ¶
type ErrModuleNotTidy ¶
type ErrModuleNotTidy struct { // Reason summarizes why the module is not tidy. Reason string }
ErrModuleNotTidy is returned by CheckTidy when a module is not tidy, such as when there are missing or unnecessary dependencies listed.
func (ErrModuleNotTidy) Error ¶
func (e ErrModuleNotTidy) Error() string
type Registry ¶
type Registry interface { modrequirements.Registry modpkgload.Registry // ModuleVersions returns all the versions for the module with the given path // sorted in semver order. // If mpath has a major version suffix, only versions with that major version will // be returned. ModuleVersions(ctx context.Context, mpath string) ([]string, error) }
Registry is modload's view of a module registry.
Source Files ¶
query.go tidy.go update.go
- Version
- v0.13.0-alpha.3
- Published
- Mar 31, 2025
- Platform
- js/wasm
- Imports
- 23 packages
- Last checked
- 16 minutes ago –
Tools for package owners.