Documentation
¶
Index ¶
- Variables
- type AddedItem
- type BreakingChange
- type ConstantContract
- type Contract
- type ContractDiff
- type DiffSummary
- type Differ
- type Extractor
- type FieldContract
- type FunctionContract
- type InterfaceContract
- type MethodContract
- type ModifiedItem
- type ParameterInfo
- type PositionInfo
- type ReceiverInfo
- type TypeContract
- type VariableContract
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilContracts = errors.New("contracts cannot be nil") ErrUnsupportedFormat = errors.New("unsupported output format") ErrNoPackagesFound = errors.New("no packages found") ErrNoGoPackagesFound = errors.New("no Go packages found in directory") ErrPackageErrors = errors.New("package compilation errors") )
Define static errors
Functions ¶
This section is empty.
Types ¶
type AddedItem ¶
type AddedItem struct { Type string `json:"type"` // "interface", "method", "function", etc. Item string `json:"item"` Description string `json:"description"` }
AddedItem represents a newly added API item
type BreakingChange ¶
type BreakingChange struct { Type string `json:"type"` // "removed_interface", "removed_method", "changed_signature", etc. Item string `json:"item"` // Name of the affected item Description string `json:"description"` OldValue string `json:"old_value,omitempty"` NewValue string `json:"new_value,omitempty"` }
BreakingChange represents a breaking API change
type ConstantContract ¶
type ConstantContract struct { Name string `json:"name"` Package string `json:"package"` Type string `json:"type"` Value string `json:"value,omitempty"` DocComment string `json:"doc_comment,omitempty"` Position PositionInfo `json:"position"` }
ConstantContract represents a package-level constant
type Contract ¶
type Contract struct { PackageName string `json:"package_name"` ModulePath string `json:"module_path,omitempty"` Version string `json:"version,omitempty"` Timestamp time.Time `json:"timestamp"` Interfaces []InterfaceContract `json:"interfaces,omitempty"` Types []TypeContract `json:"types,omitempty"` Functions []FunctionContract `json:"functions,omitempty"` Variables []VariableContract `json:"variables,omitempty"` Constants []ConstantContract `json:"constants,omitempty"` }
Contract represents the API contract of a Go package or module
func LoadFromFile ¶
LoadFromFile loads a contract from a JSON file
func (*Contract) SaveToFile ¶
SaveToFile saves the contract to a JSON file
type ContractDiff ¶
type ContractDiff struct { PackageName string `json:"package_name"` OldVersion string `json:"old_version,omitempty"` NewVersion string `json:"new_version,omitempty"` BreakingChanges []BreakingChange `json:"breaking_changes,omitempty"` AddedItems []AddedItem `json:"added_items,omitempty"` ModifiedItems []ModifiedItem `json:"modified_items,omitempty"` Summary DiffSummary `json:"summary"` }
ContractDiff represents differences between two contracts
func LoadDiffFromFile ¶
func LoadDiffFromFile(filename string) (*ContractDiff, error)
LoadDiffFromFile loads a contract diff from a JSON file
func (*ContractDiff) SaveToFile ¶
func (d *ContractDiff) SaveToFile(filename string) error
SaveToFile saves the diff to a JSON file
type DiffSummary ¶
type DiffSummary struct { TotalBreakingChanges int `json:"total_breaking_changes"` TotalAdditions int `json:"total_additions"` TotalModifications int `json:"total_modifications"` HasBreakingChanges bool `json:"has_breaking_changes"` }
DiffSummary provides a high-level summary of changes
type Differ ¶
type Differ struct { // IgnorePositions determines whether to ignore source position changes IgnorePositions bool // IgnoreComments determines whether to ignore documentation comment changes IgnoreComments bool }
Differ handles comparing two API contracts
type Extractor ¶
type Extractor struct { // IncludePrivate determines whether to include unexported items IncludePrivate bool // IncludeTests determines whether to include test files IncludeTests bool // IncludeInternal determines whether to include internal packages IncludeInternal bool }
Extractor handles API contract extraction from Go packages
func NewExtractor ¶
func NewExtractor() *Extractor
NewExtractor creates a new API contract extractor
func (*Extractor) ExtractFromDirectory ¶
ExtractFromDirectory extracts the API contract from a directory containing Go files
type FieldContract ¶
type FieldContract struct { Name string `json:"name"` Type string `json:"type"` Tag string `json:"tag,omitempty"` DocComment string `json:"doc_comment,omitempty"` Position PositionInfo `json:"position"` }
FieldContract represents a struct field
type FunctionContract ¶
type FunctionContract struct { Name string `json:"name"` Package string `json:"package"` DocComment string `json:"doc_comment,omitempty"` Parameters []ParameterInfo `json:"parameters,omitempty"` Results []ParameterInfo `json:"results,omitempty"` Position PositionInfo `json:"position"` }
FunctionContract represents a function signature
type InterfaceContract ¶
type InterfaceContract struct { Name string `json:"name"` Package string `json:"package"` DocComment string `json:"doc_comment,omitempty"` Methods []MethodContract `json:"methods,omitempty"` Embedded []string `json:"embedded,omitempty"` Position PositionInfo `json:"position"` }
InterfaceContract represents an interface definition
type MethodContract ¶
type MethodContract struct { Name string `json:"name"` DocComment string `json:"doc_comment,omitempty"` Receiver *ReceiverInfo `json:"receiver,omitempty"` Parameters []ParameterInfo `json:"parameters,omitempty"` Results []ParameterInfo `json:"results,omitempty"` Position PositionInfo `json:"position"` }
MethodContract represents a method signature
type ModifiedItem ¶
type ModifiedItem struct { Type string `json:"type"` Item string `json:"item"` Description string `json:"description"` OldValue string `json:"old_value,omitempty"` NewValue string `json:"new_value,omitempty"` }
ModifiedItem represents a modified API item (non-breaking)
type ParameterInfo ¶
ParameterInfo represents parameter or result information
type PositionInfo ¶
type PositionInfo struct { Filename string `json:"filename"` Line int `json:"line"` Column int `json:"column"` }
PositionInfo represents source position information
type ReceiverInfo ¶
type ReceiverInfo struct { Name string `json:"name,omitempty"` Type string `json:"type"` Pointer bool `json:"pointer"` }
ReceiverInfo represents method receiver information
type TypeContract ¶
type TypeContract struct { Name string `json:"name"` Package string `json:"package"` Kind string `json:"kind"` // "struct", "alias", "basic", etc. DocComment string `json:"doc_comment,omitempty"` Fields []FieldContract `json:"fields,omitempty"` Methods []MethodContract `json:"methods,omitempty"` Underlying string `json:"underlying,omitempty"` // For type aliases Position PositionInfo `json:"position"` }
TypeContract represents a type definition (struct, alias, etc.)
type VariableContract ¶
type VariableContract struct { Name string `json:"name"` Package string `json:"package"` Type string `json:"type"` DocComment string `json:"doc_comment,omitempty"` Position PositionInfo `json:"position"` }
VariableContract represents a package-level variable