Documentation
¶
Index ¶
- func GetModulePath() (string, error)
- func GetPackageDir(pkgPath string) (string, error)
- func QuickScanForDirectives(filePath string) (bool, error)
- func ResolvePackagePath(relativePath string) (string, error)
- func ScanDirectory(root string) ([]string, error)
- type InterfaceDirective
- type MethodInfo
- type PackageCache
- type PackageInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetModulePath ¶
GetModulePath returns the module path from go.mod in the current directory or parent directories
func GetPackageDir ¶
GetPackageDir uses `go list` to get the directory of a package
func QuickScanForDirectives ¶
QuickScanForDirectives does a fast text-based scan to check if a file might contain piccolo directives
func ResolvePackagePath ¶
ResolvePackagePath resolves a relative package path to a full import path
func ScanDirectory ¶
ScanDirectory recursively scans a directory for Go files with piccolo directives
Types ¶
type InterfaceDirective ¶
type InterfaceDirective struct {
FilePath string // Path to the file containing the interface
InterfaceName string // Name of the interface
PackagePath string // Package path from // piccolo: package <path>
StructNames []string // Struct names from // piccolo: struct A, B, C
MethodNames []string // Method names from // piccolo: method X, Y, Z
ImportAliases map[string]string // Import aliases from // piccolo: import-alias <pkg> <alias>
HasMarkers bool // Whether // piccolo:start and // piccolo:end markers exist
StartPos int // Byte position of interface body start (after '{')
EndPos int // Byte position of interface body end (before '}')
MarkerStart int // Byte position after // piccolo:start line (if markers exist)
MarkerEnd int // Byte position before // piccolo:end line (if markers exist)
}
InterfaceDirective represents a parsed piccolo directive for an interface
func ParseFile ¶
func ParseFile(filePath string) ([]*InterfaceDirective, error)
ParseFile parses a Go file and returns all interface directives found
type MethodInfo ¶
type MethodInfo struct {
StructName string // The struct this method belongs to
Signature string // The method signature (name + params + returns)
}
MethodInfo holds information about a method
type PackageCache ¶
type PackageCache struct {
// contains filtered or unexported fields
}
PackageCache caches parsed package information
func NewPackageCache ¶
func NewPackageCache() *PackageCache
NewPackageCache creates a new package cache
func (*PackageCache) ExtractMethods ¶
func (c *PackageCache) ExtractMethods(pkgPath string, structNames []string, methodNames []string) ([]string, error)
ExtractMethods extracts the specified methods from a package
func (*PackageCache) LoadPackage ¶
func (c *PackageCache) LoadPackage(pkgPath string) (*PackageInfo, error)
LoadPackage loads and parses a package, extracting ALL methods from ALL structs
type PackageInfo ¶
type PackageInfo struct {
Dir string // Package directory
Methods map[string]map[string]*MethodInfo // Struct name -> Method name -> MethodInfo
}
PackageInfo holds parsed package information