Documentation
¶
Index ¶
- Variables
- func DownloadPackageToCache(out io.Writer, pkgPath string, fetcher pkgdownload.PackageFetcher) error
- func LockCache(modCachePath string) (*flock.Flock, error)
- func PackageDir(importPath string) string
- func ReadPkgListFromDir(dir string, mptype gnolang.MemPackageType) (gnomod.PkgList, error)
- func StdlibDir(gnoroot string, name string) string
- type Error
- type FileImport
- type FileKind
- type FilesMap
- type ImportsMap
- type LoadConfig
- type Package
- type PkgList
- type SortedPkgList
Constants ¶
This section is empty.
Variables ¶
var ErrGnoContextNotFound = errors.New("gnowork.toml file not found in current or any parent directory and gnomod.toml doesn't exists in current directory")
var ErrGnoworkNotFound = errors.New("gnowork.toml file not found in current or any parent directory")
ErrGnoworkNotFound is returned by [findRootDir] when, even after traversing up to the root directory, a gnowork.toml file could not be found.
var ErrPackageNotFound = errors.New("package not found")
Functions ¶
func DownloadPackageToCache ¶
func DownloadPackageToCache(out io.Writer, pkgPath string, fetcher pkgdownload.PackageFetcher) error
DownloadPackageToCache downloads a remote gno package by pkg path and store it in the modcache
func LockCache ¶
LockCache ensure the modcache dir exists, attempts to lock it and returns a filelock.
func PackageDir ¶
func ReadPkgListFromDir ¶
ReadPkgListFromDir() lists all gno packages in the given dir directory. `mptype` determines what subset of files are considered to read from.
deprecated: use Load with a recursive pattern instead
Not using official deprecated syntax because our current golangcilint config enforces that deprecated function are not used and there is a bug that prevents selectively ignoring the rule, see https://github.com/golangci/golangci-lint/issues/1658
Types ¶
type FileImport ¶
type FileImport struct { PkgPath string Spec *ast.ImportSpec }
FileImport represents an import and it's location in the source file
func FileImports ¶
FileImports returns the list of gno imports in the given file src. The given filename is only used when recording position information.
type FileKind ¶
type FileKind string
FileKind represent the category a gno package file falls in, can be one of:
- FileKindPackageSource -> A *.gno file that will be included in the gnovm package
- FileKindTest -> A *_test.gno file that will be used for testing
- FileKindXTest -> A *_test.gno file with a package name ending in _test that will be used for blackbox testing
- FileKindFiletest -> A *_filetest.gno file that will be used for snapshot testing
- FileKindOther -> Any other file in the package, e.g.: *.toml, README.md, etc...
func GetFileKind ¶
GetFileKind analyzes a file's name and body to get it's FileKind, fset is optional
func GnoFileKinds ¶
func GnoFileKinds() []FileKind
type ImportsMap ¶
type ImportsMap map[FileKind][]*FileImport
func Imports ¶
func Imports(pkg *std.MemPackage, fset *token.FileSet) (ImportsMap, error)
Imports returns the list of gno imports from a std.MemPackage. fset is optional.
func (ImportsMap) Merge ¶
func (imap ImportsMap) Merge(kinds ...FileKind) []*FileImport
Merge merges imports, it removes duplicates and sorts the result
func (ImportsMap) ToStrings ¶
func (imap ImportsMap) ToStrings() map[FileKind][]string
type LoadConfig ¶
type LoadConfig struct { Fetcher pkgdownload.PackageFetcher // package fetcher used to load dependencies not present in patterns. Could be wrapped to support fetching from examples and/or an in-memory cache. Deps bool // load dependencies AllowEmpty bool // don't return error when no packages are loaded Fset *token.FileSet // external fset to help with pretty errors Out io.Writer // used to print info Test bool // load test dependencies GnoRoot string // used to override GNOROOT ExtraWorkspaceRoots []string // extra workspaces root used to find dependencies }
type Package ¶
type Package struct { Dir string `json:",omitempty"` // directory containing package sources ImportPath string `json:",omitempty"` // import path of package in dir Name string `json:",omitempty"` // package name Match []string `json:",omitempty"` // command-line patterns matching this package Errors []*Error `json:",omitempty"` // error loading this package (not dependencies) Ignore bool `json:",omitempty"` Files FilesMap `json:",omitempty"` Imports map[FileKind][]string `json:",omitempty"` // import paths used by this package ImportsSpecs ImportsMap `json:"-"` }
type PkgList ¶
type PkgList []*Package
func (PkgList) Sort ¶
func (pl PkgList) Sort() (SortedPkgList, error)
sortPkgs sorts the given packages by their dependencies.
type SortedPkgList ¶
type SortedPkgList []*Package
func (SortedPkgList) GetNonIgnoredPkgs ¶
func (sp SortedPkgList) GetNonIgnoredPkgs() SortedPkgList
GetNonIgnoredPkgs returns packages that are not draft and have no direct or indirect draft dependencies.