Documentation
¶
Index ¶
- Constants
- func ExtractCommentTags(lines []string, markers ...byte) (tags map[string][]string, otherLines []string)
- func StringifyNode(fset *token.FileSet, node ast.Node) string
- type ModInfo
- type Module
- type Package
- type Results
- type TypeAndValue
- type TypeAndValues
- type TypeName
- type TypeRef
- type Universe
Constants ¶
View Source
const ( LoadFiles = packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles LoadImports = LoadFiles | packages.NeedImports LoadTypes = LoadImports | packages.NeedTypes | packages.NeedTypesSizes LoadSyntax = LoadTypes | packages.NeedSyntax | packages.NeedTypesInfo LoadAllSyntax = LoadSyntax | packages.NeedDeps | packages.NeedModule )
Variables ¶
This section is empty.
Functions ¶
func ExtractCommentTags ¶
func ExtractCommentTags(lines []string, markers ...byte) (tags map[string][]string, otherLines []string)
ExtractCommentTags parses comments for lines of the form:
'marker' + "key=value".
Values are optional; "" is the default. A tag can be specified more than one time and all values are returned. If the resulting map has an entry for a key, the value (a slice) is guaranteed to have at least 1 element.
Example: if you pass '+' or '@' for 'marker', and the following lines are in the comments:
+foo=value1 +bar +foo value2 +baz="qux"
Then this function will return:
map[string][]string{"foo":{"value1, "value2"}, "bar": {"true"}, "baz": {"qux"}}
Types ¶
type Package ¶
type Package interface { // Pkg of go package Pkg() *types.Package // Imports of go package Imports() map[string]Package // Module of go package Module() *packages.Module // SourceDir code source absolute dir SourceDir() string // Files ast files of package Files() []*ast.File // Decl ast Decl for pos Decl(pos token.Pos) ast.Decl // Doc comment tags and leading comments for pos Doc(pos token.Pos) (map[string][]string, []string) // Comment trailing comments for pos Comment(pos token.Pos) []string // Eval eval expr in package Eval(expr ast.Expr) (types.TypeAndValue, error) // Constant get constant by name Constant(name string) *types.Const // Constants get all constants of package Constants() map[string]*types.Const // Type get type by name Type(name string) *types.TypeName // Types get all types of package Types() map[string]*types.TypeName // Function get function by name Function(name string) *types.Func // Functions get all signatures of package Functions() map[string]*types.Func // MethodsOf get methods of types.TypeName MethodsOf(n *types.Named, canPtr bool) []*types.Func // ResultsOf get possible TypeAndValue of function ResultsOf(tpe *types.Func) (results Results, resultN int) // Position get position of pos Position(pos token.Pos) token.Position // ObjectOf get object of ident ObjectOf(id *ast.Ident) types.Object }
type Results ¶
type Results []TypeAndValues
type TypeAndValue ¶
type TypeAndValue struct { // Type Type types.Type // Value not nil if can be static value Value constant.Value // Expr TypeOrValue assigned by Expr Expr ast.Expr // if Expr == *ast.CallExpr, will use this to pick value At int // if Expr == *ast.CallExpr, record all available results From Results }
func (TypeAndValue) String ¶
func (r TypeAndValue) String() string
type TypeAndValues ¶
type TypeAndValues []TypeAndValue
func (TypeAndValues) String ¶
func (typeOrValues TypeAndValues) String() string
type TypeName ¶
func MustParseRef ¶
type TypeRef ¶
func ParseTypeRef ¶
Click to show internal directories.
Click to hide internal directories.