graph

package
v1.4.48 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package graph defines the core data model for the gograph tool.

Index

Constants

View Source
const Version = "1"

Version is the schema version written into graph.json.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallEdge

type CallEdge struct {
	CallerSymbolID string `json:"caller_symbol_id"`
	CallerName     string `json:"caller_name"`
	CalleeRaw      string `json:"callee_raw"`
	File           string `json:"file"`
	Line           int    `json:"line"`
}

CallEdge records a call expression found inside a function/method body.

type ConcurrencyNode added in v1.1.5

type ConcurrencyNode struct {
	Kind     string `json:"kind"`
	Function string `json:"function"`
	File     string `json:"file"`
	Line     int    `json:"line"`
	Detail   string `json:"detail,omitempty"`
}

ConcurrencyNode represents a concurrency primitive found in code. Kind is one of: "goroutine", "channel_send", "channel_recv", "mutex_lock", "mutex_unlock", "rwmutex_lock", "rwmutex_unlock", "waitgroup_add", "waitgroup_wait", "once_do".

type Dependency added in v1.1.0

type Dependency struct {
	Module  string `json:"module"`
	Version string `json:"version"`
}

Dependency represents a go.mod dependency.

type EnvRead

type EnvRead struct {
	Key      string `json:"key"`
	Accessor string `json:"accessor"`
	File     string `json:"file"`
	Line     int    `json:"line"`
	Function string `json:"function,omitempty"`
}

EnvRead records a detected environment variable read.

type ErrorEdge added in v1.1.2

type ErrorEdge struct {
	Message  string `json:"message"`
	Function string `json:"function"`
	File     string `json:"file"`
	Line     int    `json:"line"`
}

ErrorEdge represents an extracted error message or panic.

type FileNode

type FileNode struct {
	ID          string `json:"id"`
	Path        string `json:"path"`
	PackageName string `json:"package_name"`
	Lines       int    `json:"lines"`
	Generated   bool   `json:"generated"`
}

FileNode represents a single .go source file.

type Graph

type Graph struct {
	Version      string            `json:"version"`
	GeneratedAt  time.Time         `json:"generated_at"`
	Root         string            `json:"root"`
	Packages     []PackageNode     `json:"packages"`
	Files        []FileNode        `json:"files"`
	Symbols      []SymbolNode      `json:"symbols"`
	Imports      []ImportEdge      `json:"imports"`
	Calls        []CallEdge        `json:"calls"`
	EnvReads     []EnvRead         `json:"env_reads"`
	Dependencies []Dependency      `json:"dependencies"`
	Routes       []HTTPRoute       `json:"routes,omitempty"`
	SQLs         []SQLEdge         `json:"sqls,omitempty"`
	Errors       []ErrorEdge       `json:"errors,omitempty"`
	Concurrency  []ConcurrencyNode `json:"concurrency,omitempty"`
	TestEdges    []TestEdge        `json:"test_edges,omitempty"`
	Implements   []ImplementsEdge  `json:"implements,omitempty"`
	Mutations    []MutationEdge    `json:"mutations,omitempty"`
}

Graph is the top-level data structure written to .gograph/graph.json.

type HTTPRoute added in v1.1.2

type HTTPRoute struct {
	Method  string `json:"method"`
	Path    string `json:"path"`
	Handler string `json:"handler"`
	File    string `json:"file"`
	Line    int    `json:"line"`
}

HTTPRoute represents an HTTP REST endpoint found in the AST.

type ImplementsEdge added in v1.4.12

type ImplementsEdge struct {
	Interface string `json:"interface"`
	Concrete  string `json:"concrete"`
}

ImplementsEdge records absolute proof that a concrete type implements an interface.

type ImportEdge

type ImportEdge struct {
	FromFile    string `json:"from_file"`
	FromPackage string `json:"from_package"`
	ImportPath  string `json:"import_path"`
	Alias       string `json:"alias,omitempty"`
}

ImportEdge records an import statement in a file.

type MutationEdge added in v1.4.17

type MutationEdge struct {
	Field    string `json:"field"`
	Function string `json:"function"`
	File     string `json:"file"`
	Line     int    `json:"line"`
}

MutationEdge represents an assignment to a struct field.

type PackageNode

type PackageNode struct {
	ID                   string   `json:"id"`
	Name                 string   `json:"name"`
	ImportPathBestEffort string   `json:"import_path_best_effort"`
	Dir                  string   `json:"dir"`
	Files                []string `json:"files"`
}

PackageNode represents a Go package found in the repository.

type SQLEdge added in v1.1.2

type SQLEdge struct {
	Query    string `json:"query"`
	Function string `json:"function"`
	File     string `json:"file"`
	Line     int    `json:"line"`
}

SQLEdge represents an extracted SQL query.

type StructField added in v1.1.2

type StructField struct {
	Name string `json:"name"`
	Type string `json:"type"`
	Tag  string `json:"tag,omitempty"`
}

StructField represents a field inside a struct.

type SymbolKind

type SymbolKind string

SymbolKind categorises a symbol.

const (
	KindFunction  SymbolKind = "function"
	KindMethod    SymbolKind = "method"
	KindStruct    SymbolKind = "struct"
	KindInterface SymbolKind = "interface"
	KindVar       SymbolKind = "var"
	KindConst     SymbolKind = "const"
)

type SymbolNode

type SymbolNode struct {
	ID               string            `json:"id"`
	Kind             SymbolKind        `json:"kind"`
	Name             string            `json:"name"`
	Receiver         string            `json:"receiver,omitempty"`
	PackageName      string            `json:"package_name"`
	File             string            `json:"file"`
	Line             int               `json:"line"`
	EndLine          int               `json:"end_line"`
	Doc              string            `json:"doc,omitempty"`
	Signature        string            `json:"signature,omitempty"`
	MethodSignature  string            `json:"method_signature,omitempty"`
	InterfaceMethods map[string]string `json:"interface_methods,omitempty"`
	StructFields     []StructField     `json:"struct_fields,omitempty"`
	EmbeddedStructs  []string          `json:"embedded_structs,omitempty"`
	Arity            int               `json:"arity,omitempty"`
}

SymbolNode represents a named symbol (function, method, struct, interface).

type TestEdge added in v1.1.5

type TestEdge struct {
	TestFunc string `json:"test_func"`
	Target   string `json:"target"` // callee name that looks like a production symbol
	File     string `json:"file"`
	Line     int    `json:"line"`
}

TestEdge links a *testing.T test function to the symbols it exercises.

Jump to

Keyboard shortcuts

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