fastmod

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: BSD-3-Clause Imports: 12 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 (*Package) DepImportList

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

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
)

type PkgsIndex

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

type Version

type Version struct {
	Path    string
	Version string
}

Directories

Path Synopsis
internal
module
Package module defines the module.Version type along with support code.
Package module defines the module.Version type along with support code.
semver
Package semver implements comparison of semantic version strings.
Package semver implements comparison of semantic version strings.

Jump to

Keyboard shortcuts

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