Documentation
¶
Index ¶
- Variables
- func CreateGnoModFile(rootDir, modPath string) error
- func FindRootDir(absPath string) (string, error)
- func ModCachePath() string
- func ModulePath(mod []byte) string
- func PackageDir(root string, v module.Version) string
- type File
- func (f *File) AddReplace(oldPath, oldVers, newPath, newVers string)
- func (f *File) DropReplace(oldPath, oldVers string)
- func (f *File) GetGno() (version string)
- func (f *File) Resolve(m module.Version) module.Version
- func (f *File) Sanitize()
- func (f *File) SetComment(text string)
- func (f *File) SetGno(version string)
- func (f *File) SetModule(path string)
- func (f *File) Validate() error
- func (f *File) WriteFile(fpath string) error
- func (f *File) WriteString() string
- type Pkg
- type PkgList
- type SortedPkgList
- type SubPkg
Constants ¶
This section is empty.
Variables ¶
var ErrGnoModNotFound = errors.New("gno.mod file not found in current or any parent directory")
ErrGnoModNotFound is returned by FindRootDir when, even after traversing up to the root directory, a gno.mod file could not be found.
var ErrNoModFile = errors.New("gno.mod doesn't exist")
Functions ¶
func CreateGnoModFile ¶
func FindRootDir ¶
FindRootDir determines the root directory of the project which contains the gno.mod file. If no gno.mod file is found, ErrGnoModNotFound is returned. The given path must be absolute.
func ModulePath ¶
ModulePath returns the module path from the gomod file text. If it cannot find a module path, it returns an empty string. It is tolerant of unrelated problems in the go.mod file.
func PackageDir ¶
PackageDir resolves a given module.Version to the path on the filesystem. If root is dir, it is defaulted to the value of ModCachePath.
Types ¶
type File ¶
type File struct { Draft bool Module *modfile.Module Gno *modfile.Go Replace []*modfile.Replace Syntax *modfile.FileSyntax }
Parsed gno.mod file.
func MustParseMemPackage ¶
func MustParseMemPackage(mpkg *std.MemPackage) *File
Must parse gno.mod from MemPackage.
func ParseBytes ¶
ParseBytes parses and returns a gno.mod file.
- fname is the name of the file, used in positions and errors. - data is the content of the file.
func ParseDir ¶
ParseDir parses, validates and returns a gno.mod file located at dir or at dir's parents.
func ParseFilepath ¶
Tries to parse gno mod file given the file path, using ParseBytes and Validate.
func ParseMemPackage ¶
func ParseMemPackage(mpkg *std.MemPackage) (*File, error)
Parse gno.mod from MemPackage, or return nil and error.
func (*File) AddReplace ¶
func (*File) DropReplace ¶
func (*File) Resolve ¶
Resolve takes a module version and returns any adequate replacement following the Replace directives.
func (*File) SetComment ¶
type PkgList ¶
type PkgList []Pkg
func (PkgList) Sort ¶
func (pl PkgList) Sort() (SortedPkgList, error)
sortPkgs sorts the given packages by their dependencies.
type SortedPkgList ¶
type SortedPkgList []Pkg
func (SortedPkgList) GetNonDraftPkgs ¶
func (sp SortedPkgList) GetNonDraftPkgs() SortedPkgList
GetNonDraftPkgs returns packages that are not draft and have no direct or indirect draft dependencies.
type SubPkg ¶
type SubPkg struct { Dir string // absolute path to package dir ImportPath string // import path of package Root string // Root dir containing this package, i.e dir containing gno.mod file Imports []string // imports used by this package GnoFiles []string // .gno source files (excluding TestGnoFiles, FiletestGnoFiles) TestGnoFiles []string // _test.gno source files FiletestGnoFiles []string // _filetest.gno source files }
func GnoFileSubPkg ¶
GnoFileSubPkg returns a subpackage from the given .gno files.
func SubPkgsFromPaths ¶
SubPkgsFromPaths returns a list of subpackages from the given paths.