Documentation ¶
Index ¶
- func Call(p *types.Func) string
- func CompatibleTypes(expected types.Type, actual types.Type) error
- func Dump(val interface{}) string
- func Funcs() template.FuncMap
- func ImportPathForDir(dir string) (res string)
- func LcFirst(s string) string
- func NameForDir(dir string) string
- func NormalizeVendor(pkg string) string
- func PackageNameFromFile(file string) string
- func PkgAndType(name string) (string, string)
- func QualifyPackagePath(importPath string) string
- func SanitizePackageName(pkg string) string
- func ToGo(name string) string
- func ToGoPrivate(name string) string
- func TypeIdentifier(t types.Type) string
- func UcFirst(s string) string
- type Import
- type Imports
- type Packages
- func (p *Packages) Errors() PkgErrors
- func (p *Packages) Evict(importPath string)
- func (p *Packages) Load(importPath string) *packages.Package
- func (p *Packages) LoadAll(importPaths ...string) []*packages.Package
- func (p *Packages) LoadWithTypes(importPath string) *packages.Package
- func (p *Packages) NameForPackage(importPath string) string
- type PkgErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompatibleTypes ¶
CompatibleTypes isnt a strict comparison, it allows for pointer differences
func ImportPathForDir ¶
ImportPathForDir takes a path and returns a golang import path for the package
func NameForDir ¶
NameForDir manually looks for package stanzas in files located in the given directory. This can be much faster than having to consult go list, because we already know exactly where to look.
func NormalizeVendor ¶
NormalizeVendor takes a qualified package path and turns it into normal one.
func PackageNameFromFile ¶
func PkgAndType ¶
take a string in the form github.com/package/blah.Type and split it into package and type
func QualifyPackagePath ¶
QualifyPackagePath takes an import and fully qualifies it with a vendor dir, if one is required.
func SanitizePackageName ¶
func ToGoPrivate ¶
func TypeIdentifier ¶
Types ¶
type Imports ¶
var CurrentImports *Imports
CurrentImports keeps track of all the import declarations that are needed during the execution of a plugin. this is done with a global because subtemplates currently get called in functions. Lets aim to remove this eventually.
type Packages ¶
type Packages struct {
// contains filtered or unexported fields
}
packages is a wrapper around x/tools/go/packages that maintains a (hopefully prewarmed) cache of packages that can be invalidated as writes are made and packages are known to change.
func (*Packages) Errors ¶
Errors returns any errors that were returned by Load, either from the call itself or any of the loaded packages.
func (*Packages) Evict ¶
Evict removes a given package import path from the cache, along with any packages that depend on it. Further calls to Load will fetch it from disk.
func (*Packages) LoadAll ¶
LoadAll will call packages.Load and return the package data for the given packages, but if the package already have been loaded it will return cached values instead.
func (*Packages) LoadWithTypes ¶
LoadWithTypes tries a standard load, which may not have enough type info (TypesInfo== nil) available if the imported package is a second order dependency. Fortunately this doesnt happen very often, so we can just issue a load when we detect it.
func (*Packages) NameForPackage ¶
NameForPackage looks up the package name from the package stanza in the go files at the given import path.