golang

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBeegoFactory

func NewBeegoFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewBeegoFactory creates a Source for the Beego web framework.

func NewBuffaloFactory

func NewBuffaloFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewBuffaloFactory creates a Source for the Buffalo web framework.

func NewChiFactory

func NewChiFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewChiFactory creates a Source for the Chi HTTP framework.

func NewEchoFactory

func NewEchoFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewEchoFactory creates a Source for the Echo web framework.

func NewFastHTTPFactory

func NewFastHTTPFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewFastHTTPFactory creates a Source for the FastHTTP high-performance HTTP package.

func NewFiberFactory

func NewFiberFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewFiberFactory creates a Source for the Fiber web framework.

func NewGinFactory

func NewGinFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewGinFactory creates a Source for the Gin web framework.

func NewGoFrameFactory

func NewGoFrameFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewGoFrameFactory creates a Source for the GoFrame web framework.

func NewGoZeroFactory

func NewGoZeroFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewGoZeroFactory creates a Source for the go-zero microservice framework.

func NewGorillaMuxFactory

func NewGorillaMuxFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewGorillaMuxFactory creates a Source for the Gorilla Mux HTTP router.

func NewGormFactory

func NewGormFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewGormFactory creates a Source for the GORM ORM library.

func NewHertzFactory

func NewHertzFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewHertzFactory creates a Source for the Hertz HTTP framework.

func NewIrisFactory

func NewIrisFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewIrisFactory creates a Source for the Iris web framework.

func NewKratosFactory

func NewKratosFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewKratosFactory creates a Source for the Kratos microservice framework.

func NewRevelFactory

func NewRevelFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewRevelFactory creates a Source for the Revel web framework.

func NewStdlibFactory

func NewStdlibFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

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 New

func New(repoPath string, cfg Config) *Source

New constructs a Go Source pointing at a local clone of a Go package.

func (*Source) DetectWrapper

func (s *Source) DetectWrapper(method *source.Method) (bool, string, string)

DetectWrapper analyzes a method's source code for wrapper patterns.

func (*Source) DiscoverEntities

func (s *Source) DiscoverEntities(ctx context.Context, fetch source.FetchFunc) ([]string, error)

DiscoverEntities walks the local repository and returns entity identifiers for all exported Go types, functions, and constants.

func (*Source) ID

func (s *Source) ID() string

ID returns the canonical library ID.

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

func (s *Source) ParseSourceCode(entityID string, content []byte) (string, error)

ParseSourceCode extracts source code for a specific entity from file content.

func (*Source) ResolveWrapperURL

func (s *Source) ResolveWrapperURL(targetName, targetKind, entitySlug string) string

ResolveWrapperURL constructs a URL for a wrapped target.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL