Documentation
¶
Overview ¶
Package tree provides utilities for parsing and formatting Go packages.
Index ¶
- type Function
- type Options
- type Package
- func (p *Package) ConstantNames() []string
- func (p *Package) Format() (string, error)
- func (p *Package) FormatWithOptions(opts *Options) (string, error)
- func (p *Package) FunctionNames() []string
- func (p *Package) GetFunction(name string) *Function
- func (p *Package) GetType(name string) *Type
- func (p *Package) Imports() []string
- func (p *Package) Name() string
- func (p *Package) TypeNames() []string
- func (p *Package) VariableNames() []string
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function represents a function in a parsed Go package
func (*Function) ReceiverType ¶
ReceiverType returns the receiver type for methods, or empty string for functions
type Options ¶
type Options struct { // IncludeTestFiles determines whether to include test files in parsing IncludeTestFiles bool // PreserveFormattingStyle determines whether to preserve the original formatting style // If false, Go's standard formatting will be applied PreserveFormattingStyle bool // SkipComments determines whether to skip comments during parsing SkipComments bool // CustomPackageName sets a custom package name for formatting // If empty, the original package name will be used CustomPackageName string }
Options configures the behavior of the parser and formatter
type Package ¶
Package represents a parsed Go package
func ParseWithOptions ¶
ParseWithOptions parses a Go package from the given directory with the specified options
func (*Package) ConstantNames ¶
ConstantNames returns the names of all constants in the package
func (*Package) FormatWithOptions ¶
FormatWithOptions formats a Package into a single Go source file with the specified options
func (*Package) FunctionNames ¶
FunctionNames returns the names of all functions in the package
func (*Package) GetFunction ¶
GetFunction returns a function by name, or nil if not found
func (*Package) VariableNames ¶
VariableNames returns the names of all variables in the package
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type represents a type in a parsed Go package
func (*Type) IsInterface ¶
IsInterface returns true if the type is an interface