gocuelang.org/go/mod/modcache Index | Files

package modcache

import "cuelang.org/go/mod/modcache"

Package modcache provides a file-based cache for modules.

WARNING: THIS PACKAGE IS EXPERIMENTAL. ITS API MAY CHANGE AT ANY TIME.

Index

Functions

func RemoveAll

func RemoveAll(dir string) error

RemoveAll removes a directory written by the cache, first applying any permission changes needed to do so.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func New

func New(registry *modregistry.Client, dir string) (*Cache, error)

New returns r wrapped inside a caching layer that stores persistent cached content inside the given OS directory, typically ${CUE_CACHE_DIR}.

The `module.SourceLoc.FS` fields in the locations returned by the registry implement the `OSRootFS` interface, allowing a caller to find the native OS filepath where modules are stored.

The returned type implements [modconfig.Registry] and [modconfig.CachedRegistry].

func (*Cache) Fetch

func (c *Cache) Fetch(ctx context.Context, mv module.Version) (module.SourceLoc, error)

Fetch returns the location of the contents for the given module version, downloading it if necessary.

func (*Cache) FetchFromCache

func (c *Cache) FetchFromCache(mv module.Version) (module.SourceLoc, error)

FetchFromCache implements cuelang.org/go/mod/modconfig.CachedRegistry.

func (*Cache) ModuleVersions

func (c *Cache) ModuleVersions(ctx context.Context, mpath string) ([]string, error)

ModuleVersions implements [modload.Registry.ModuleVersions].

func (*Cache) Requirements

func (c *Cache) Requirements(ctx context.Context, mv module.Version) ([]module.Version, error)

Source Files

cache.go fetch.go

Version
v0.13.0-alpha.3
Published
Mar 31, 2025
Platform
linux/amd64
Imports
19 packages
Last checked
4 minutes ago

Tools for package owners.