fastmod

package module
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: BSD-3-Clause Imports: 11 Imported by: 3

README

Fast parse Go modules

go get github.com/visualfc/fastmod

Usages:

pkg, err := fastmod.LoadPackage(dir, &build.Default)
if err != nil {
	return
}
path, dir, typ := pkg.Lookup(pkg)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPkgModPath

func GetPkgModPath(ctx *build.Context) string

func LookupModFile

func LookupModFile(dir string) (string, error)

Types

type Mod

type Mod struct {
	Require *Version
	Replace *Version
}

func (*Mod) EncodeVersionPath

func (m *Mod) EncodeVersionPath() string

func (*Mod) VersionPath

func (m *Mod) VersionPath() string

type Module

type Module struct {
	Mods []*Mod
	// contains filtered or unexported fields
}

func (*Module) Lookup

func (m *Module) Lookup(pkg string) (path string, dir string, typ PkgType)

func (*Module) ModDir

func (m *Module) ModDir() string

func (*Module) ModFile

func (m *Module) ModFile() string

func (*Module) Path

func (m *Module) Path() string

type ModuleList

type ModuleList struct {
	Modules map[string]*Module
	// contains filtered or unexported fields
}

func NewModuleList

func NewModuleList(ctx *build.Context) *ModuleList

func (*ModuleList) LoadModule

func (mc *ModuleList) LoadModule(dir string) (*Module, error)

func (*ModuleList) LoadModuleFile

func (mc *ModuleList) LoadModuleFile(fmod string) (*Module, error)

type Node

type Node struct {
	*Module
	Parent   *Node
	Children []*Node
}

type Package

type Package struct {
	ModList *ModuleList
	Root    *Node
	NodeMap map[string]*Node
	// contains filtered or unexported fields
}

func LoadPackage

func LoadPackage(dir string, ctx *build.Context) (*Package, error)

func NewPackage added in v1.2.0

func NewPackage(ctx *build.Context) *Package

func (*Package) Clear added in v1.2.0

func (p *Package) Clear()

func (*Package) DepImportList

func (p *Package) DepImportList(skipcmd bool, chkmodsub bool) []string

func (*Package) IsStd added in v1.3.3

func (p *Package) IsStd() bool

func (*Package) IsValid added in v1.2.0

func (p *Package) IsValid() bool

func (*Package) LoadModule added in v1.2.0

func (p *Package) LoadModule(dir string) (err error)

func (*Package) LocalImportList

func (p *Package) LocalImportList(skipcmd bool) []string

func (*Package) Lookup

func (p *Package) Lookup(pkg string) (path string, dir string, typ PkgType)

func (*Package) Node

func (p *Package) Node() *Node

type PathPkgsIndex

type PathPkgsIndex struct {
	Indexs []*PkgsIndex
}

func (*PathPkgsIndex) LoadIndex

func (p *PathPkgsIndex) LoadIndex(context build.Context, srcDirs ...string)

func (*PathPkgsIndex) Sort

func (p *PathPkgsIndex) Sort()

type PkgSlice

type PkgSlice []*build.Package

func (PkgSlice) Len

func (p PkgSlice) Len() int

func (PkgSlice) Less

func (p PkgSlice) Less(i, j int) bool

func (PkgSlice) Swap

func (p PkgSlice) Swap(i, j int)

type PkgType

type PkgType int
const (
	PkgTypeNil      PkgType = iota
	PkgTypeGoroot           // goroot pkg
	PkgTypeGopath           // gopath pkg
	PkgTypeMod              // mod pkg
	PkgTypeLocal            // mod pkg sub local
	PkgTypeLocalMod         // mod pkg sub local mod
	PkgTypeDepMod           // mod pkg dep gopath/pkg/mod
	PkgTypeVendor
)

type PkgsIndex

type PkgsIndex struct {
	sync.Mutex
	Pkgs []*build.Package
}

type Version

type Version struct {
	Path    string
	Version string
}

Jump to

Keyboard shortcuts

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