golang

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildGoPackageExportIndices

func BuildGoPackageExportIndices(dirToFiles map[string][]string, contentReader vcs.ContentReader) map[string]GoPackageExportIndex

func BuildIntraPackageDependencies

func BuildIntraPackageDependencies(filePaths []string, contentReader vcs.ContentReader) (map[string][]string, error)

BuildIntraPackageDependencies builds dependencies between files in the same Go package. The contentReader function is used to read file contents, allowing the caller to control whether files are read from the filesystem, a git commit, or another source.

func GetUsedSymbolsFromPackage

func GetUsedSymbolsFromPackage(exportInfo *GoExportInfo, importPath string) map[string]bool

GetUsedSymbolsFromPackage extracts which symbols from a specific import path are actually used

func IsTestFile

func IsTestFile(filePath string) bool

IsTestFile reports whether the given Go file path is a test file.

func ResolveGoProjectImports

func ResolveGoProjectImports(
	absPath string,
	filePath string,
	dirToFiles map[string][]string,
	goPackageExportIndices map[string]GoPackageExportIndex,
	suppliedFiles map[string]bool,
	contentReader vcs.ContentReader,
) ([]string, error)

Types

type ExternalImport

type ExternalImport struct {
	// contains filtered or unexported fields
}

ExternalImport represents an external module import

func (ExternalImport) Path

func (e ExternalImport) Path() string

type GoEmbed

type GoEmbed struct {
	Pattern string // The embed pattern (file path or glob)
}

GoEmbed represents an embedded file from a //go:embed directive

func ParseGoEmbeds

func ParseGoEmbeds(sourceCode []byte) ([]GoEmbed, error)

ParseGoEmbeds parses Go source code and extracts //go:embed directives

type GoExportInfo

type GoExportInfo struct {
	FilePath      string
	Package       string
	Exports       map[string]bool            // Exported symbols (capitalized) defined in this file
	ImportAliases map[string]string          // Maps import path to alias used (or package name if no alias)
	DotImports    map[string]bool            // Tracks import paths imported via dot import
	QualifiedRefs map[string]map[string]bool // Maps package alias -> set of symbols accessed
	UnqualRefs    map[string]bool            // Unqualified refs, used for dot-import symbol filtering
}

GoExportInfo tracks exported symbols and import usage in a Go file

func ExtractGoExportInfo

func ExtractGoExportInfo(filePath string) (*GoExportInfo, error)

ExtractGoExportInfo analyzes a Go file and extracts exported symbols and import usage

func ExtractGoExportInfoFromContent

func ExtractGoExportInfoFromContent(filePath string, content []byte) (*GoExportInfo, error)

ExtractGoExportInfoFromContent analyzes Go source code and extracts exported symbols and import usage

type GoImport

type GoImport interface {
	Path() string
}

GoImport represents an import in a Go file

func GoImports

func GoImports(filePath string) ([]GoImport, error)

GoImports parses a Go file and returns its imports

func ParseGoImports

func ParseGoImports(sourceCode []byte) ([]GoImport, error)

ParseGoImports parses Go source code and extracts imports

type GoPackageExportIndex

type GoPackageExportIndex map[string][]string // symbol name -> list of files defining it

GoPackageExportIndex maps exported symbols to their defining files within a package directory

func BuildPackageExportIndex

func BuildPackageExportIndex(filePaths []string, contentReader vcs.ContentReader) (GoPackageExportIndex, error)

BuildPackageExportIndex builds an index of exported symbols for files in a package directory. The contentReader function is used to read file contents, allowing the caller to control whether files are read from the filesystem, a git commit, or another source.

type GoSymbolInfo

type GoSymbolInfo struct {
	FilePath   string
	Package    string
	Defined    map[string]bool // Symbols defined in this file
	Referenced map[string]bool // Symbols referenced in this file
}

GoSymbolInfo tracks symbols defined and referenced in a Go file

func ExtractGoSymbols

func ExtractGoSymbols(filePath string) (*GoSymbolInfo, error)

ExtractGoSymbols analyzes a Go file and extracts defined and referenced symbols

func ExtractGoSymbolsFromContent

func ExtractGoSymbolsFromContent(filePath string, content []byte) (*GoSymbolInfo, error)

ExtractGoSymbolsFromContent analyzes Go source code and extracts defined and referenced symbols

type InternalImport

type InternalImport struct {
	// contains filtered or unexported fields
}

InternalImport represents an internal project import

func (InternalImport) Path

func (i InternalImport) Path() string

type Module

type Module struct{}

func (Module) Extensions

func (Module) Extensions() []string

func (Module) IsTestFile

func (Module) IsTestFile(filePath string, _ vcs.ContentReader) bool

func (Module) Maturity

func (Module) Maturity() langsupport.MaturityLevel

func (Module) Name

func (Module) Name() string

func (Module) NewResolver

func (Module) NewResolver(ctx *langsupport.Context, contentReader vcs.ContentReader) langsupport.Resolver

type ProjectImportResolver

type ProjectImportResolver struct {
	// contains filtered or unexported fields
}

ProjectImportResolver encapsulates Go-specific dependency resolution caches and logic.

func NewProjectImportResolver

func NewProjectImportResolver(
	dirToFiles map[string][]string,
	suppliedFiles map[string]bool,
	contentReader vcs.ContentReader,
) *ProjectImportResolver

NewProjectImportResolver creates a Go dependency resolver with precomputed package export indices.

func (*ProjectImportResolver) ResolveProjectImports

func (r *ProjectImportResolver) ResolveProjectImports(absPath, filePath string) ([]string, error)

ResolveProjectImports resolves Go project imports for a single file using cached indices.

type StandardLibraryImport

type StandardLibraryImport struct {
	// contains filtered or unexported fields
}

StandardLibraryImport represents a Go standard library import

func (StandardLibraryImport) Path

func (s StandardLibraryImport) Path() string

Jump to

Keyboard shortcuts

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