Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Method ¶
Method represents a method of some interface.
type Package ¶
type Package struct {
// Absolute path to this package
Dir string
// All package names declared by any source file (usually just 1 or 2!)
Names []string
// All interfaces defined in any source file
Interfaces []Interface
}
Package is a package that contains interfaces.
func NewPackage ¶
NewPackage loads *.go from a given directory and returns type information about the package defined in it.
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
Params is the set of parameters to a method.
func (*Params) NameList ¶
NameList is a comma-separated list of parameter names, including variadic (without trailing dots)
func (*Params) Tuple ¶
Tuple is the formal parameters declaration surrounded by parentheses e.g. "(alice string, bob int)"
type Resolver ¶
type Resolver interface {
// Resolve transforms an absolute path-and-typename into an imported type with
// a package-unique nickname. The "local" package name must be given, and if
// it is the same as the type's package's assigned nickname, the prefix is
// omitted.
Resolve(local, typePath string) string
// Import idempotently adds a package to the resolver's dictionary with a
// chosen nickname. Returns true if addition was succesful, or if the package
// is already registered with that name.
Import(nick, impPath string) bool
// Imports provides a map of nickname-to-package.
Imports() map[string]string
}
Resolver assigns unique file-local import names ("nicknames") to packages that will be imported and used in a Go source file. It works with several string representations of packages; to avoid confusion, please keep in mind the following terminology:
nick, local: one-word, file-local nicknames e.g. "os", "mypkg" typePath: absolute type paths e.g. "/usr/local/src/foo.Widget", "sort.Interface" impPath: relative import paths e.g. "net/url", "github.com/xeger/bar"
func NewResolver ¶
func NewResolver() Resolver
NewResolver creates a simple resolver that keeps state with a pair of maps.
type Results ¶
type Results []Type
Results are the type(s) returned by an interface method.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type represents a Go data type.
func (Type) BareName ¶
BareName returns the name of ultimate, underlying basic or named type, free from any pointer/slice/map decorators or package names. For maps, it returns the underlying key type instead of the value type.
func (Type) ShortName ¶
ShortName returns the type's name as usable from within a Go source file. You must pass a Resolver to handle package import names, as well as the package name declared in the source file in which this type name will appear.