Documentation ¶
Index ¶
- Variables
- func CreateGnoModFile(rootDir, modPath string) error
- func FindRootDir(absPath string) (string, error)
- func GetGnoModPath() 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) AddNewRequire(path, vers string, indirect bool)
- func (f *File) AddReplace(oldPath, oldVers, newPath, newVers string) error
- func (f *File) AddRequire(path, vers string) error
- func (f *File) DropReplace(oldPath, oldVers string) error
- func (f *File) DropRequire(path string) error
- func (f *File) FetchDeps(path string, remote string, verbose bool) error
- func (f *File) Resolve(r *modfile.Require) 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 GetGnoModPath.
Types ¶
type File ¶
type File struct { Draft bool Module *modfile.Module Go *modfile.Go Require []*modfile.Require Replace []*modfile.Replace Syntax *modfile.FileSyntax }
Parsed gno.mod file.
func GnoToGoMod ¶
GnoToGoMod make necessary modifications in the gno.mod and return go.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) AddNewRequire ¶
AddNewRequire adds a new require line for path at version vers at the end of the last require block, regardless of any existing require lines for path.
func (*File) AddReplace ¶
func (*File) AddRequire ¶
AddRequire sets the first require line for path to version vers, preserving any existing comments for that line and removing all other lines for path.
If no line currently exists for path, AddRequire adds a new line at the end of the last require block.
func (*File) DropReplace ¶
func (*File) DropRequire ¶
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.