Documentation
¶
Overview ¶
Package golang provides a Source interface implementation for parsing Go source code. It supports any Go package (stdlib, Gin, Echo, GORM, etc.) by walking Go source directories, extracting exported types, functions, and methods via tree-sitter, and detecting wrapper delegation patterns.
Index ¶
- func NewBeegoFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewBuffaloFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewChiFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewEchoFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewFastHTTPFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewFiberFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewGinFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewGoFrameFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewGoZeroFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewGorillaMuxFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewGormFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewHertzFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewIrisFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewKratosFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewRevelFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewStdlibFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- type Config
- type Source
- func (s *Source) DetectWrapper(method *source.Method) (bool, string, string)
- func (s *Source) DiscoverEntities(ctx context.Context, fetch source.FetchFunc) ([]string, error)
- func (s *Source) ID() string
- func (s *Source) Meta() source.LibraryMeta
- func (s *Source) ParseEntity(ctx context.Context, entityID string, content []byte) (*source.Entity, []string, error)
- func (s *Source) ParseMethod(ctx context.Context, methodID string, content []byte) (*source.Method, error)
- func (s *Source) ParseSourceCode(entityID string, content []byte) (string, error)
- func (s *Source) ResolveWrapperURL(targetName, targetKind, entitySlug string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBeegoFactory ¶
NewBeegoFactory creates a Source for the Beego web framework.
func NewBuffaloFactory ¶
NewBuffaloFactory creates a Source for the Buffalo web framework.
func NewChiFactory ¶
NewChiFactory creates a Source for the Chi HTTP framework.
func NewEchoFactory ¶
NewEchoFactory creates a Source for the Echo web framework.
func NewFastHTTPFactory ¶
NewFastHTTPFactory creates a Source for the FastHTTP high-performance HTTP package.
func NewFiberFactory ¶
NewFiberFactory creates a Source for the Fiber web framework.
func NewGinFactory ¶
NewGinFactory creates a Source for the Gin web framework.
func NewGoFrameFactory ¶
NewGoFrameFactory creates a Source for the GoFrame web framework.
func NewGoZeroFactory ¶
NewGoZeroFactory creates a Source for the go-zero microservice framework.
func NewGorillaMuxFactory ¶
NewGorillaMuxFactory creates a Source for the Gorilla Mux HTTP router.
func NewGormFactory ¶
NewGormFactory creates a Source for the GORM ORM library.
func NewHertzFactory ¶
NewHertzFactory creates a Source for the Hertz HTTP framework.
func NewIrisFactory ¶
NewIrisFactory creates a Source for the Iris web framework.
func NewKratosFactory ¶
NewKratosFactory creates a Source for the Kratos microservice framework.
func NewRevelFactory ¶
NewRevelFactory creates a Source for the Revel web framework.
func NewStdlibFactory ¶
NewStdlibFactory creates a Source for the Go standard library.
Types ¶
type Config ¶
type Config struct {
// LibraryID is the canonical library identifier (e.g., "go/stdlib", "go/gin").
LibraryID string
// Name is the human-readable library name.
Name string
// Description is a short description of the library.
Description string
// SourceURL is the upstream repository URL.
SourceURL string
// Ref is the git tag/branch for source-code link generation.
Ref string
// RootDirs are the directories to walk for discovery relative to repoPath.
// Empty means walk the entire repoPath.
RootDirs []string
// ExcludeDirs are directory names to skip during discovery.
ExcludeDirs []string
// GitHubOwnerRepo is "owner/repo" for generating GitHub blob URLs.
// If empty, source URLs will be file-relative.
GitHubOwnerRepo string
}
Config defines the settings for a Go source adapter instance.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source implements the source.Source interface for Go packages.
func (*Source) DetectWrapper ¶
DetectWrapper analyzes a method's source code for wrapper patterns.
func (*Source) DiscoverEntities ¶
DiscoverEntities walks the local repository and returns entity identifiers for all exported Go types, functions, and constants.
func (*Source) Meta ¶
func (s *Source) Meta() source.LibraryMeta
Meta returns metadata for the library record.
func (*Source) ParseEntity ¶
func (s *Source) ParseEntity(ctx context.Context, entityID string, content []byte) (*source.Entity, []string, error)
ParseEntity parses a single Go entity from file content.
func (*Source) ParseMethod ¶
func (s *Source) ParseMethod(ctx context.Context, methodID string, content []byte) (*source.Method, error)
ParseMethod parses a method on a type from file content.
func (*Source) ParseSourceCode ¶
ParseSourceCode extracts source code for a specific entity from file content.
func (*Source) ResolveWrapperURL ¶
ResolveWrapperURL constructs a URL for a wrapped target.