modcache

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitPathVersion

func SplitPathVersion(pathVersion string) (path, version string, err error)

SplitPathVersion splits a path@version into path & version

func WriteFS

func WriteFS(modules Modules) (fs.FS, error)

Write modules directly into the cache directory in an acceptable format so that Go thinks these files are cached and doesn't try reading them from the network.

This implementation is the minimal format needed to get `go mod tidy` to think the files are cached. This shouldn't be used outside of testing contexts.

Based on: https://github.com/golang/go/blob/master/src/cmd/go/internal/modfetch/fetch.go

Types

type Cache

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

func Default

func Default() *Cache

Default loads a module cache from the default location

func New

func New(cacheDir string) *Cache

New module cache relative to the cache directory

func (*Cache) Directory

func (c *Cache) Directory(subpaths ...string) string

Directory returns the cache directory joined with optional subpaths

func (*Cache) Export

func (c *Cache) Export(to string) error

Export to a directory

func (*Cache) Import

func (c *Cache) Import(from string) error

Import from a directory

func (*Cache) ResolveDirectory

func (c *Cache) ResolveDirectory(modulePath, version string) (string, error)

ResolveDirectory returns the directory to which m should have been downloaded. An error will be returned if the module path or version cannot be escaped. An error satisfying errors.Is(err, os.ErrNotExist) will be returned along with the directory if the directory does not exist or if the directory is not completely populated.

func (*Cache) Write

func (c *Cache) Write(modules Modules) error

Write modules directly into the cache directory in an acceptable format so that Go thinks these files are cached and doesn't try reading them from the network.

This implementation is the minimal format needed to get `go mod tidy` to think the files are cached. This shouldn't be used outside of testing contexts.

Based on: https://github.com/golang/go/blob/master/src/cmd/go/internal/modfetch/fetch.go

type Files

type Files = map[string]string

type Modules

type Modules = map[string]Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL