Documentation ¶
Index ¶
- Variables
- func GuessPackageFromDir(dir string) (pkg *build.Package, err error)
- func IsGoModDir(dir string) bool
- type Module
- type ModuleError
- type PackageList
- func (t *PackageList) AddPackage(pkg *build.Package)
- func (t *PackageList) Len() int
- func (t *PackageList) LookupByDir(dir string) *build.Package
- func (t *PackageList) LookupByName(name string) *build.Package
- func (t *PackageList) Map() map[*build.Package]bool
- func (t *PackageList) RemoveByDir(dir string)
- func (t *PackageList) RemoveByName(name string)
- func (t *PackageList) RemovePackage(pkg *build.Package)
- func (t *PackageList) Sorted() []*build.Package
Constants ¶
This section is empty.
Variables ¶
var (
ErrorImpossibleImportDir1 = errutil.NewFactory("guess the import package info failed from %q")
)
errors
Functions ¶
func GuessPackageFromDir ¶
GuessPackageFromDir return importable package from dir if possible
func IsGoModDir ¶
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 ¶
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) 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