gnomod

package
v0.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

View Source
var ErrNoModFile = errors.New("gno.mod doesn't exist")

Functions

func CreateGnoModFile

func CreateGnoModFile(rootDir, modPath string) error

func FindRootDir

func FindRootDir(absPath string) (string, error)

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 ModCachePath

func ModCachePath() string

ModCachePath returns the path for gno modules

func ModulePath

func ModulePath(mod []byte) string

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

func PackageDir(root string, v module.Version) string

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

func ParseBytes(fname string, data []byte) (*File, error)

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

func ParseDir(dir string) (*File, error)

ParseDir parses, validates and returns a gno.mod file located at dir or at dir's parents.

func ParseFilepath

func ParseFilepath(fpath string) (*File, error)

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 (f *File) AddReplace(oldPath, oldVers, newPath, newVers string)

func (*File) DropReplace

func (f *File) DropReplace(oldPath, oldVers string)

func (*File) GetGno

func (f *File) GetGno() (version string)

func (*File) Resolve

func (f *File) Resolve(m module.Version) module.Version

Resolve takes a module version and returns any adequate replacement following the Replace directives.

func (*File) Sanitize

func (f *File) Sanitize()

func (*File) SetComment

func (f *File) SetComment(text string)

func (*File) SetGno

func (f *File) SetGno(version string)

func (*File) SetModule

func (f *File) SetModule(path string)

func (*File) Validate

func (f *File) Validate() error

Validate validates gno.mod

func (*File) WriteFile

func (f *File) WriteFile(fpath string) error

writes file to the given absolute file path

func (*File) WriteString

func (f *File) WriteString() string

writes to a string

type Pkg

type Pkg struct {
	Dir     string   // absolute path to package dir
	Name    string   // package name
	Imports []string // direct imports of this pkg
	Draft   bool     // whether the package is a draft
}

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

func GnoFileSubPkg(files []string) (*SubPkg, error)

GnoFileSubPkg returns a subpackage from the given .gno files.

func SubPkgsFromPaths

func SubPkgsFromPaths(paths []string) ([]*SubPkg, error)

SubPkgsFromPaths returns a list of subpackages from the given paths.

Jump to

Keyboard shortcuts

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