A Go source code analysis module for Memex that creates a queryable graph of code structure and relationships.
Install directly from git:
memex module install https://github.com/systemshift/memex-ast.git
memex module enable ast# Parse a single file
memex ast parse file.go
# Parse a directory
memex ast parse ./pkg/...# Show type relationships
memex ast types
# Show call graph
memex ast calls
# Find interface implementations
memex ast impls io.Reader
# Show package dependencies
memex ast deps# Find all implementations of an interface
memex query "type:ast.struct -[ast.implements]-> {name: 'io.Reader'}"
# Show function call chain
memex query "type:ast.function -[ast.calls*]-> {name: 'main'}"
# Find unused types
memex query "type:ast.struct -[!ast.uses]->"
# Show package dependencies
memex query "type:ast.package -[ast.imports]-> type:ast.package"The module analyzes Go source code using:
go/ast: AST parsinggo/parser: Go source parsinggo/token: Token handling
ast.package: Package declarationsast.function: Functions and methodsast.struct: Struct definitionsast.interface: Interface definitionsast.field: Struct fieldsast.method: Interface methodsast.import: Package imports
ast.calls: Function callsast.implements: Interface implementationsast.contains: Package/type containmentast.imports: Package dependenciesast.embeds: Type embeddingast.uses: Type usage
This is a memex module and requires memex to be installed. It's designed to be installed directly from git rather than run as a standalone binary.
go test ./...# Clone the repository
git clone https://github.com/systemshift/memex-ast.git
# Install locally for testing
memex module install ./memex-ast
# Make changes and reinstall to test
memex module remove ast
memex module install ./memex-ast