inspect

package
v0.11.10 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package inspect provides deterministic codebase inspection functionality.

Package inspect provides deterministic codebase inspection functionality.

Package inspect provides deterministic codebase inspection functionality.

Package inspect provides deterministic codebase inspection functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllSourceFiles

func GetAllSourceFiles(dir string) ([]string, error)

GetAllSourceFiles returns all Go source files (including test files) in a directory.

func GetSourceFiles

func GetSourceFiles(dir string) ([]string, error)

GetSourceFiles returns a list of Go source files in a directory (excluding test files).

func ReadSourceFile

func ReadSourceFile(baseDir, path string) (string, error)

ReadSourceFile reads a Go source file and returns its contents. The path is validated to ensure it's within the base directory. #nosec G304 - Path is validated via validatePath to ensure it's within baseDir

func ReadSourceFiles

func ReadSourceFiles(baseDir string, paths []string) (map[string]string, error)

ReadSourceFiles reads multiple Go source files and returns their contents. Paths are validated to ensure they're within the base directory.

Types

type ExportedInterface

type ExportedInterface struct {
	Name    string
	Doc     string
	Methods []InterfaceMethod
}

ExportedInterface represents an exported interface in a package.

func ExtractInterfaces

func ExtractInterfaces(dir string) ([]ExportedInterface, error)

ExtractInterfaces extracts all exported interfaces from a package directory using go/packages.

type ExportedType

type ExportedType struct {
	Name     string
	Doc      string
	TypeKind string // "struct", "interface", "type alias", etc.
}

ExportedType represents an exported type in a package.

func ExtractTypes

func ExtractTypes(dir string) ([]ExportedType, error)

ExtractTypes extracts all exported types from a package directory using go/packages.

type InterfaceMethod

type InterfaceMethod struct {
	Name      string
	Doc       string
	Signature string
}

InterfaceMethod represents a method in an interface.

type ModFile

type ModFile struct {
	Module    string
	GoVersion string
	Requires  []Require
	Replaces  []Replace
}

ModFile represents a parsed go.mod file.

func ParseGoMod

func ParseGoMod(path string) (*ModFile, error)

ParseGoMod parses a go.mod file and returns its contents as a ModFile struct. The path is validated to ensure it's within the base directory. #nosec G304 - Path is validated via validatePath to ensure it's within baseDir

func ParseModContent

func ParseModContent(content string) (*ModFile, error)

ParseModContent parses go.mod content from a string.

type PackageInfo

type PackageInfo struct {
	ImportPath string
	Dir        string
	Name       string
	Files      []string
}

PackageInfo represents information about a Go package.

func ListPackages

func ListPackages(patterns ...string) ([]PackageInfo, error)

ListPackages runs `go list` and returns information about packages.

func ListPackagesInDir

func ListPackagesInDir(dir string, patterns ...string) ([]PackageInfo, error)

ListPackagesInDir runs `go list` in a specific directory.

type Replace

type Replace struct {
	OldPath    string
	OldVersion string
	NewPath    string
	NewVersion string
}

Replace represents a replace directive in go.mod.

type Require

type Require struct {
	Path     string
	Version  string
	Indirect bool
}

Require represents a require directive in go.mod.

Jump to

Keyboard shortcuts

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