Skip to content

feat(graph): add Go language extractor - #133

Open
0xmohit wants to merge 1 commit into
mex-memory:mainfrom
0xmohit:feat/go-code-graph-extractor
Open

feat(graph): add Go language extractor#133
0xmohit wants to merge 1 commit into
mex-memory:mainfrom
0xmohit:feat/go-code-graph-extractor

Conversation

@0xmohit

@0xmohit 0xmohit commented Aug 22, 2026

Copy link
Copy Markdown

Add code-graph extraction support for Go using tree-sitter-go grammar (https://github.com/tree-sitter/tree-sitter-go).

  • New src/graph/extraction/languages/go.ts with GoWalker extracting: structs (class), interfaces, type aliases, functions, methods, generics, imports, calls, struct instantiations, field types.
  • New fixture src/graph/__tests__/fixtures/sample.go and 11 tests in extractor-go.test.ts covering declarations, containment, references, generics, and docstrings.
  • Register Go in languages/index.ts and grammars.ts (.go extension).
  • Vendor tree-sitter-go.wasm from tree-sitter-wasms@0.1.13.

Update docs: docs/code-graph-support.md (Go now Supported), docs/extractors.md (grammar source documentation).

Fix src/graph/extraction/node-id.ts: add guard in getNodeText() for nodes missing startIndex/endIndex (tree-sitter-go comment nodes lack byte offsets when accessed via previousSibling).

Fixes #93


What

Why

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Docs
  • CI/Tooling

How to test

Checklist

  • Tests pass (npm test)
  • No breaking changes (or documented below)
  • Tested locally with a real project

Code-graph changes

  • This PR targets main
  • A linked issue agrees on the bounded extractor/resolver scope
  • The change follows the frozen LanguageExtractor or FrameworkResolver interface
  • A focused fixture and assertions for the expected node/edge shape are included
  • Any new grammar WASM, extension mapping, extractor, or resolver is registered
  • No graph identity, reconciliation, schema, or drift-semantics changes are included, or a core / discuss-first issue is linked above

Add code-graph extraction support for Go using tree-sitter-go grammar
(https://github.com/tree-sitter/tree-sitter-go).

- New `src/graph/extraction/languages/go.ts` with `GoWalker` extracting:
  structs (class), interfaces, type aliases, functions, methods,
  generics, imports, calls, struct instantiations, field types.
- New fixture `src/graph/__tests__/fixtures/sample.go` and 11 tests in
  `extractor-go.test.ts` covering declarations, containment, references,
  generics, and docstrings.
- Register Go in `languages/index.ts` and `grammars.ts` (`.go` extension).
- Vendor `tree-sitter-go.wasm` from tree-sitter-wasms@0.1.13.

Update docs: `docs/code-graph-support.md` (Go now Supported),
`docs/extractors.md` (grammar source documentation).

Fix `src/graph/extraction/node-id.ts`: add guard in `getNodeText()` for
nodes missing `startIndex`/`endIndex` (tree-sitter-go comment nodes lack
byte offsets when accessed via `previousSibling`).

Fixes mex-memory#93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go] Add code-graph extractor

1 participant