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) AddComment(text string)
- func (f *File) AddModuleStmt(path string) error
- func (f *File) AddReplace(oldPath, oldVers, newPath, newVers string) error
- func (f *File) DropReplace(oldPath, oldVers string) error
- func (f *File) Resolve(m module.Version) module.Version
- func (f *File) Sanitize()
- func (f *File) Validate() error
- func (f *File) Write(fname string) error
- 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.
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 Go *modfile.Go Replace []*modfile.Replace Syntax *modfile.FileSyntax }
Parsed gno.mod file.
func Parse ¶
Parse parses and returns a gno.mod file.
- file is the name of the file, used in positions and errors. - data is the content of the file.
func ParseAt ¶
ParseAt parses, validates and returns a gno.mod file located at dir or at dir's parents.
func ParseGnoMod ¶
tries to parse gno mod file given the filename, using Parse and Validate from the gnomod package
TODO(tb): replace by `gnomod.ParseAt` ? The key difference is the latter looks for gno.mod in parent directories, while this function doesn't.
func (*File) AddComment ¶
func (*File) AddModuleStmt ¶
func (*File) AddReplace ¶
func (*File) DropReplace ¶
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.