pkgutil

package
v0.0.0-...-c6ea6ab Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: LGPL-3.0 Imports: 12 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorImpossibleImportDir1 = errutil.NewFactory("guess the import package info failed from %q")
)

errors

Functions

func GuessPackageFromDir

func GuessPackageFromDir(dir string) (pkg *build.Package, err error)

GuessPackageFromDir return importable package from dir if possible

func IsGoModDir

func IsGoModDir(dir string) bool

IsGoModDir return true if dir contains go.mod file

Types

type Module

type Module struct {
	Path     string       // module path
	Version  string       // module version
	Versions []string     // available module versions (with -versions)
	Replace  *Module      // replaced by this module
	Time     *time.Time   // time version was created
	Update   *Module      // available update, if any (with -u)
	Main     bool         // is this the main module?
	Indirect bool         // is this module only an indirect dependency of main module?
	Dir      string       // directory holding files for this module, if any
	GoMod    string       // path to go.mod file for this module, if any
	Error    *ModuleError // error loading module
}

Module go mod info

func ParseGoMod

func ParseGoMod(dir string) (result []Module, err error)

ParseGoMod return go module and dep info in dir

type ModuleError

type ModuleError struct {
	Err string // the error itself
}

ModuleError go mod error

type PackageList

type PackageList struct {
	// contains filtered or unexported fields
}

PackageList contains Package info and support lookup efficiently

func FindAllSubPackages

func FindAllSubPackages(importPath string, srcDir string) (pkglist *PackageList, err error)

FindAllSubPackages return all sub packages under importPath

func ParsePackagePaths

func ParsePackagePaths(srcDir string, paths ...string) (pkglist *PackageList, err error)

ParsePackagePaths return PackageList by parse paths, ignore vendor

func (*PackageList) AddPackage

func (t *PackageList) AddPackage(pkg *build.Package)

AddPackage add pkg into PackageList

func (*PackageList) Len

func (t *PackageList) Len() int

Len return length of PackageList

func (*PackageList) LookupByDir

func (t *PackageList) LookupByDir(dir string) *build.Package

LookupByDir lookup Package by dir

func (*PackageList) LookupByName

func (t *PackageList) LookupByName(name string) *build.Package

LookupByName lookup Package by import path

func (*PackageList) Map

func (t *PackageList) Map() map[*build.Package]bool

Map return packages in map form

func (*PackageList) RemoveByDir

func (t *PackageList) RemoveByDir(dir string)

RemoveByDir remove pkg from PackageList by dir

func (*PackageList) RemoveByName

func (t *PackageList) RemoveByName(name string)

RemoveByName remove pkg from PackageList by import path

func (*PackageList) RemovePackage

func (t *PackageList) RemovePackage(pkg *build.Package)

RemovePackage remove pkg from PackageList

func (*PackageList) Sorted

func (t *PackageList) Sorted() []*build.Package

Sorted return packages in slice form and sorted by package directory

Jump to

Keyboard shortcuts

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