Help us shape the future of Go! Take the 2026 Go Developer Survey

db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlackHoleResult

type BlackHoleResult struct {
	FunctionName        string
	FilePath            string
	InboundDependencies int64
}

type BoundaryRule added in v0.2.0

type BoundaryRule struct {
	FromPattern string `json:"from_pattern"`
	ToPattern   string `json:"to_pattern"`
}

type BoundaryViolation added in v0.2.0

type BoundaryViolation struct {
	Type         string `json:"type"` // "CALL" or "IMPORT"
	FromPath     string `json:"from_path"`
	FromSymbol   string `json:"from_symbol,omitempty"`
	ToPath       string `json:"to_path"`
	ToSymbol     string `json:"to_symbol,omitempty"`
	RuleViolated string `json:"rule_violated"`
}
type CallChainLink struct {
	CallerName string `json:"caller_name"`
	CallerFile string `json:"caller_file"`
	CalleeName string `json:"callee_name"`
	CalleeFile string `json:"callee_file"`
}

type ClassEntity

type ClassEntity struct {
	ID           string
	Name         string
	FilePath     string
	Docstring    string
	TypeCategory string // e.g. "class", "struct", "interface"
	ASTHash      string
}

type CloneGroup added in v0.2.0

type CloneGroup struct {
	ASTHash   string         `json:"ast_hash"`
	Functions []SearchResult `json:"functions"`
}

type CycleResult

type CycleResult struct {
	FilePath string
}

type Database

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

Database wraps the Kùzu database instance and its connection.

func NewDatabase

func NewDatabase(dbPath string) (*Database, error)

NewDatabase opens the Kùzu database at the specified path and runs DDL schema initialization.

func (*Database) Close

func (d *Database) Close()

Close closes the connection and database.

func (*Database) CreateCalls

func (d *Database) CreateCalls(callerID, calleeID string) error

CreateCalls creates a CALLS edge.

func (*Database) CreateContainsClassToEntity

func (d *Database) CreateContainsClassToEntity(classID, entityID, entityType string) error

CreateContainsClassToEntity creates a CONTAINS edge from Class to Function/Variable.

func (*Database) CreateContainsFileToEntity

func (d *Database) CreateContainsFileToEntity(filePath, entityID, entityType string) error

CreateContainsFileToEntity creates a CONTAINS edge from File to Function/Class/Variable.

func (*Database) CreateImplements

func (d *Database) CreateImplements(fromID, toID string) error

CreateImplements creates an IMPLEMENTS edge between Classes/Interfaces.

func (*Database) CreateImportsFileToEntity

func (d *Database) CreateImportsFileToEntity(fromPath, entityID, entityType string) error

CreateImportsFileToEntity creates an IMPORTS edge from File to Class/Function/Variable.

func (*Database) CreateImportsFileToFile

func (d *Database) CreateImportsFileToFile(fromPath, toPath string) error

CreateImportsFileToFile creates an IMPORTS edge between files.

func (*Database) DeleteFileEntities

func (d *Database) DeleteFileEntities(filePath string) error

DeleteFileEntities deletes all nodes and relationships associated with a file path (delta update).

func (*Database) ExportGraph

func (d *Database) ExportGraph() ([]VisNode, []VisEdge, error)

func (*Database) FileExists added in v0.1.1

func (d *Database) FileExists(path string) (bool, error)

FileExists returns true if a File node with the given path exists in the database.

func (*Database) FindClassIDByName

func (d *Database) FindClassIDByName(name string) (string, error)

FindClassIDByName returns the ID of the first Class with the given name, or "" if not found.

func (*Database) GetBlackHoles

func (d *Database) GetBlackHoles() ([]BlackHoleResult, error)

GetBlackHoles returns functions with high inbound dependencies (heavily called).

func (*Database) GetBoundaryViolations added in v0.2.0

func (d *Database) GetBoundaryViolations(rules []BoundaryRule) ([]BoundaryViolation, error)

GetBoundaryViolations identifies calls and imports that violate layer/module restrictions.

func (*Database) GetCallChain

func (d *Database) GetCallChain(targetFunction string, depth int) ([]CallChainLink, error)

GetCallChain traces all upstream callers of the target function up to depth.

func (*Database) GetClones added in v0.2.0

func (d *Database) GetClones() ([]CloneGroup, error)

GetClones finds functions that have the exact same structural AST hash.

func (*Database) GetCycles

func (d *Database) GetCycles() ([]CycleResult, error)

GetCycles detects cyclic dependencies (circular imports between files).

func (*Database) GetDeadCode

func (d *Database) GetDeadCode() ([]DeadCodeResult, error)

GetDeadCode detects functions that are not called and are not exported.

func (*Database) GetDeepCallChains added in v0.2.0

func (d *Database) GetDeepCallChains(minDepth int) ([]DeepCallChainResult, error)

GetDeepCallChains returns call chains where caller invocations exceed minDepth (e.g., depth >= 4).

func (*Database) GetDiffData added in v0.2.0

func (d *Database) GetDiffData() (*DiffData, error)

GetDiffData returns all database data needed for diffing.

func (*Database) GetFileStructure

func (d *Database) GetFileStructure(filePath string) ([]FileStructureItem, error)

GetFileStructure returns the hierarchical contents of a file.

func (*Database) GetFunctionRange added in v0.2.0

func (d *Database) GetFunctionRange(id string) (string, int64, int64, error)

GetFunctionRange retrieves the file path, start line, and end line for a function by its ID.

func (*Database) GetGodObjects

func (d *Database) GetGodObjects() ([]GodObjectResult, error)

GetGodObjects returns classes with high outbound complexity (contains many methods/variables).

func (*Database) GetStats added in v0.2.0

func (d *Database) GetStats() (int64, int64, int64, int64, error)

GetStats returns total function count, total class count, interface count, and concrete class count.

func (*Database) InsertClass

func (d *Database) InsertClass(c ClassEntity) error

InsertClass inserts a class node.

func (*Database) InsertFile

func (d *Database) InsertFile(path, hash string, lastModified int64) error

InsertFile inserts a file node.

func (*Database) InsertFunction

func (d *Database) InsertFunction(fn FunctionEntity) error

InsertFunction inserts a function node.

func (*Database) InsertVariable

func (d *Database) InsertVariable(v VariableEntity) error

InsertVariable inserts a variable node.

func (*Database) IsEmpty

func (d *Database) IsEmpty() (bool, error)

IsEmpty returns true if there are no File nodes in the database.

func (*Database) IsReadOnly added in v0.1.1

func (d *Database) IsReadOnly() bool

IsReadOnly returns true if the database was opened in read-only mode.

func (*Database) SearchCodebase

func (d *Database) SearchCodebase(query string) ([]SearchResult, error)

SearchCodebase executes search over functions, classes, and variables.

type DeadCodeResult

type DeadCodeResult struct {
	FunctionName string
	FilePath     string
}

type DeepCallChainResult added in v0.2.0

type DeepCallChainResult struct {
	CallerName string `json:"caller_name"`
	CallerFile string `json:"caller_file"`
	CalleeName string `json:"callee_name"`
	CalleeFile string `json:"callee_file"`
	Depth      int    `json:"depth"`
}

type DiffData added in v0.2.0

type DiffData struct {
	Files       []FileEntity
	Functions   []FunctionEntity
	Classes     []ClassEntity
	Variables   []VariableEntity
	ContainsRel map[string]string // maps child ID to parent class name
	Edges       []VisEdge
}

type FileEntity added in v0.2.0

type FileEntity struct {
	Path string
	Hash string
}

type FileStructureItem

type FileStructureItem struct {
	Type      string `json:"type"`
	Name      string `json:"name"`
	ClassName string `json:"class_name,omitempty"`
	StartLine int64  `json:"start_line,omitempty"`
	EndLine   int64  `json:"end_line,omitempty"`
}

type FunctionEntity

type FunctionEntity struct {
	ID         string
	Name       string
	FilePath   string
	StartLine  int64
	EndLine    int64
	Docstring  string
	IsExported bool
	ASTHash    string
}

Entity types for mapping in Go code

type GodObjectResult

type GodObjectResult struct {
	ClassName          string
	FilePath           string
	OutboundComplexity int64
}

type SearchResult

type SearchResult struct {
	Type      string `json:"type"`
	Name      string `json:"name"`
	FilePath  string `json:"file_path"`
	StartLine int64  `json:"start_line,omitempty"`
}

type VariableEntity

type VariableEntity struct {
	ID       string
	Name     string
	FilePath string
	TypeHint string
}

type VisEdge

type VisEdge struct {
	From  string `json:"from"`
	To    string `json:"to"`
	Label string `json:"label"`
}

type VisNode

type VisNode struct {
	ID    string `json:"id"`
	Label string `json:"label"`
	Group string `json:"group"`
	Title string `json:"title,omitempty"`
}

Jump to

Keyboard shortcuts

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