Documentation ¶
Index ¶
- Variables
- func Absolute(dir string) (abs string, err error)
- func Infer(dir string) string
- func WithFSCache(cache *fscache.Cache) func(o *option)
- func WithModCache(cache *modcache.Cache) func(o *option)
- type File
- func (f *File) AddReplace(oldPath, oldVers, newPath, newVers string) error
- func (f *File) AddRequire(importPath, version string) error
- func (f *File) Format() []byte
- func (f *File) Import(subpaths ...string) string
- func (f *File) Replace(oldPath, newPath string) error
- func (f *File) Replaces() (reps []*Replace)
- func (f *File) Requires() (reqs []*Require)
- type Module
- func (m *Module) DirFS(subpaths ...string) vfs.ReadWritable
- func (m *Module) Directory(subpaths ...string) string
- func (m *Module) File() *File
- func (m *Module) Find(importPath string) (*Module, error)
- func (m *Module) FindIn(fsys fs.FS, importPath string) (*Module, error)
- func (m *Module) Hash() []byte
- func (m *Module) Import(subpaths ...string) string
- func (m *Module) IsLocal(importPath string) bool
- func (m *Module) ModCache() string
- func (m *Module) Open(name string) (fs.File, error)
- func (m *Module) ReadDir(name string) ([]fs.DirEntry, error)
- func (m *Module) ResolveDirectory(importPath string) (directory string, err error)
- func (m *Module) ResolveDirectoryIn(localFS fs.FS, importPath string) (directory string, err error)
- func (m *Module) ResolveImport(directory string) (importPath string, err error)
- func (m *Module) Stat(name string) (fs.FileInfo, error)
- type Option
- type Replace
- type Require
- type Version
Constants ¶
This section is empty.
Variables ¶
var ErrCantInfer = errors.New("mod: unable to infer the module path")
ErrCantInfer occurs when you can't infer the module path from the $GOPATH.
var ErrFileNotFound = fmt.Errorf("unable to find go.mod: %w", fs.ErrNotExist)
ErrFileNotFound occurs when no go.mod can be found
Functions ¶
func Absolute ¶
Absolute traverses up the filesystem until it finds a directory containing go.mod or returns an error trying.
func WithFSCache ¶
WithFileCache uses a file cache
func WithModCache ¶
WithModCache uses a custom mod cache instead of the default
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) AddReplace ¶
func (*File) AddRequire ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) DirFS ¶
func (m *Module) DirFS(subpaths ...string) vfs.ReadWritable
DirFS returns an OS filesystem you can read and write from. TODO: remove vfs.ReadWritable
func (*Module) FindIn ¶
Find a dependency from an import path within fsys Note: go.mod itself needs to really be in the filesystem
func (*Module) ResolveDirectory ¶
ResolveDirectory resolves an import to an absolute path
func (*Module) ResolveDirectoryIn ¶
ResolveDirectory resolves an import to an absolute path. LocalFS maybe used if we're resolving an import path from within the current modules filesystem.
func (*Module) ResolveImport ¶
ResolveImport returns an import path from a local directory.