packages

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGnoContextNotFound = errors.New("gnowork.toml file not found in current or any parent directory and gnomod.toml doesn't exists in current directory")
View Source
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.

View Source
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

func LockCache(modCachePath string) (*flock.Flock, error)

LockCache ensure the modcache dir exists, attempts to lock it and returns a filelock.

func PackageDir

func PackageDir(importPath string) string

func ReadPkgListFromDir

func ReadPkgListFromDir(dir string, mptype gnolang.MemPackageType) (gnomod.PkgList, error)

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

func StdlibDir

func StdlibDir(gnoroot string, name string) string

Types

type Error

type Error struct {
	Pos string // "file:line:col" or "file:line" or "" or "-"
	Msg string
}

func (Error) Error

func (err Error) Error() string

type FileImport

type FileImport struct {
	PkgPath string
	Spec    *ast.ImportSpec
}

FileImport represents an import and it's location in the source file

func FileImports

func FileImports(filename string, src string, fset *token.FileSet) ([]*FileImport, error)

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...

const (
	FileKindUnknown       FileKind = ""
	FileKindPackageSource FileKind = "PackageSource"
	FileKindTest          FileKind = "Test"
	FileKindXTest         FileKind = "XTest"
	FileKindFiletest      FileKind = "Filetest"
	FileKindOther         FileKind = "Other"
)

func GetFileKind

func GetFileKind(filename string, body string, fset *token.FileSet) FileKind

GetFileKind analyzes a file's name and body to get it's FileKind, fset is optional

func GnoFileKinds

func GnoFileKinds() []FileKind

type FilesMap

type FilesMap map[FileKind][]string

func (FilesMap) Merge

func (fm FilesMap) Merge(kinds ...FileKind) []string

Merge merges imports, it removes duplicates and sorts the result

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 Load

func Load(conf LoadConfig, patterns ...string) (PkgList, error)

func (PkgList) Get

func (pl PkgList) Get(pkgPath string) *Package

func (PkgList) GetByDir

func (pl PkgList) GetByDir(dir string) *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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL