Documentation ¶
Overview ¶
pkginfo keeps package information of an application for gottani. It also implements types.Importer for parsing files and checking types.
Index ¶
- type PackageInfo
- func (ip *PackageInfo) AllPackages() []*build.Package
- func (ip *PackageInfo) FileSet() *token.FileSet
- func (ip *PackageInfo) GetAstFiles(bp *build.Package) []*ast.File
- func (ip *PackageInfo) GetBuildPackage(importPath, dir string) *build.Package
- func (ip *PackageInfo) GetTypesPackage(bp *build.Package) *types.Package
- func (ip *PackageInfo) Import(path string) (*types.Package, error)
- func (ip *PackageInfo) ImportFrom(path, dir string, mode types.ImportMode) (*types.Package, error)
- func (ip *PackageInfo) Load(dir string) error
- func (ip *PackageInfo) Packages() []*build.Package
- func (ip *PackageInfo) Root() *build.Package
- func (ip *PackageInfo) TypesInfo() *types.Info
- func (ip *PackageInfo) WalkPackages(prune func(*build.Package) bool, pre Walker, post Walker)
- type Walker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PackageInfo ¶
type PackageInfo struct {
// contains filtered or unexported fields
}
PackageInfo represents information of packages used by a applicaion for gottani. It also implements types.Importer for parsing and type-checking.
func New ¶
func New(dir string) (*PackageInfo, error)
New creates PackageInfo with default setting and then Load the given dir
func NewPackageInfo ¶
func NewPackageInfo(fset *token.FileSet, tinfo *types.Info) *PackageInfo
NewPackageInfo creates PackageInfo
func (*PackageInfo) AllPackages ¶
func (ip *PackageInfo) AllPackages() []*build.Package
Packages returns a slice of *build.Packages that are depended by the loaded package.
func (*PackageInfo) FileSet ¶
func (ip *PackageInfo) FileSet() *token.FileSet
FileSet() returns the *token.FileSet that holds all source code for whole the application except standard packages.
func (*PackageInfo) GetAstFiles ¶
func (ip *PackageInfo) GetAstFiles(bp *build.Package) []*ast.File
GetTypesPackage() returns the slice of *ast.File for the package specified by the given bp. It includs Go files and Cgo files.
func (*PackageInfo) GetBuildPackage ¶
func (ip *PackageInfo) GetBuildPackage(importPath, dir string) *build.Package
GetBuildPackage() returns the *build.Package coresponds for the given importPath on the given dir.
func (*PackageInfo) GetTypesPackage ¶
func (ip *PackageInfo) GetTypesPackage(bp *build.Package) *types.Package
GetTypesPackage() returns the *type.Package for the package specified by the given bp.
func (*PackageInfo) Import ¶
func (ip *PackageInfo) Import(path string) (*types.Package, error)
Import imports package specified by the path and returns its type information
func (*PackageInfo) ImportFrom ¶
func (ip *PackageInfo) ImportFrom(path, dir string, mode types.ImportMode) (*types.Package, error)
Import imports package specified by the given path and dir, then returns its type information The mode must be set 0. It is reserved for future use.
func (*PackageInfo) Load ¶
func (ip *PackageInfo) Load(dir string) error
Load loads package information of the application given by the dir
func (*PackageInfo) Packages ¶
func (ip *PackageInfo) Packages() []*build.Package
Packages returns a slice of *build.Packages that are depended by the loaded package and non standard ones.
func (*PackageInfo) Root ¶
func (ip *PackageInfo) Root() *build.Package
Root() returns the package that is in the directory given on Load().
func (*PackageInfo) TypesInfo ¶
func (ip *PackageInfo) TypesInfo() *types.Info
TypesInfo() returns the *types.Info that holds all type information for whole the application.
func (*PackageInfo) WalkPackages ¶
WalkPackages travarse packages and do the given pre and/or post function for each package