v0.3.0¶
Release Date: 2026-05-09
Release featuring semantic Go analysis with type resolution, interface detection, and comprehensive analyzer documentation.
Highlights¶
- Semantic Go extractor using
go/typesfor type-resolved call graphs - Interface implementation detection across packages
- Framework detection for Gin, Echo, Chi, Fiber, Gorilla, and httprouter
- HTTP handler detection for entry point identification
- Analyzer documentation with step-by-step implementation guides
Semantic Go Analysis¶
The new SemanticExtractor complements the existing AST-based Go extractor by adding type information from golang.org/x/tools/go/packages.
Type-Resolved Call Graphs¶
Unlike AST-based extraction which only sees syntactic function calls, semantic analysis resolves actual types:
// AST sees: variable.Method()
// Semantic sees: (*http.Client).Do() -> resolves to net/http.(*Client).Do
This enables:
- Accurate cross-package call tracking
- Virtual method resolution
- Generic instantiation tracking
Interface Implementation Detection¶
Automatically detects which types implement which interfaces:
type Handler interface {
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
type MyHandler struct{}
func (h *MyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {}
// Creates edge: type_MyHandler --[implements]--> type_Handler
Framework Detection¶
The semantic extractor identifies Go web framework usage:
| Framework | Detection Method |
|---|---|
| Gin | *gin.Engine, *gin.Context |
| Echo | *echo.Echo, echo.Context |
| Chi | chi.Router, chi.Mux |
| Fiber | *fiber.App, *fiber.Ctx |
| Gorilla Mux | *mux.Router |
| httprouter | *httprouter.Router |
Framework info is attached to handler nodes:
HTTP Handler Detection¶
Entry points are identified by analyzing function signatures:
// Detected as HTTP handler (stdlib)
func myHandler(w http.ResponseWriter, r *http.Request)
// Detected as Gin handler
func ginHandler(c *gin.Context)
// Detected as Echo handler
func echoHandler(c echo.Context) error
Using the Semantic Extractor¶
The semantic extractor runs alongside the AST extractor:
import (
"github.com/plexusone/graphize/pkg/extract/golang"
)
// Create semantic extractor for a directory
extractor := golang.NewSemanticExtractor("/path/to/project")
// Load packages with type information
if err := extractor.LoadPackage("."); err != nil {
log.Fatal(err)
}
// Extract with type resolution
nodes, edges, err := extractor.ExtractFile("main.go", "/path/to/project")
Edge Types¶
The semantic extractor produces these edge types:
| Edge Type | Description |
|---|---|
calls |
Type-resolved function/method calls |
implements |
Interface implementation |
embeds |
Struct embedding |
uses_type |
Type references in signatures |
Node Attributes¶
Enhanced nodes include:
type: function
label: handleRequest
attrs:
signature: "func(ctx context.Context, req *Request) (*Response, error)"
receiver: "*Server"
is_handler: true
framework: gin
http_method: POST
Analyzer Documentation¶
New documentation for creating custom language analyzers:
Documentation Structure¶
docs/analyzers/
├── index.md # Architecture overview
├── creating-analyzers.md # Step-by-step guide
├── go-analyzer.md # Go analyzer reference
└── semantic-analysis.md # Type analysis guide
Creating a Custom Analyzer¶
- Implement the
LanguageExtractorinterface - Register with the provider registry
- Handle file detection and extraction
- Optionally detect frameworks
See Creating Analyzers for the full guide.
Dependencies¶
New dependencies for semantic analysis:
golang.org/x/tools # go/packages for type checking
golang.org/x/mod # Module resolution (indirect)
golang.org/x/sync # Concurrent loading (indirect)
Upgrading from v0.2.0¶
No breaking changes. The semantic extractor is additive.
To use semantic analysis in your workflow:
- The semantic extractor is available but not yet integrated into the CLI
- Use it programmatically via
pkg/extract/golang.SemanticExtractor - Future releases will add
--semanticflag tographize analyze
Performance Considerations¶
Semantic analysis is more expensive than AST parsing:
| Operation | AST | Semantic |
|---|---|---|
| Single file | ~1ms | ~50ms |
| 100 files | ~100ms | ~2s |
| Type resolution | No | Yes |
| Cross-package | Limited | Full |
Use semantic analysis when you need:
- Accurate interface relationships
- Cross-package call resolution
- Framework-aware analysis
Use AST analysis for:
- Fast incremental updates
- Large codebases
- Basic structure extraction