Skip to content

[Go] Add code-graph extractor #93

Description

@theDakshJaitly

Target branch: main

Goal

Add a Go extractor against the frozen LanguageExtractor interface. The first version should model common package structure, declarations, and call relationships using only syntax available in an individual Go source file.

Scope

  • Detect .go files as go.
  • Vendor and register a compatible Tree-sitter Go WASM grammar.
  • Emit a file node and containment tree.
  • Extract functions, receiver methods, structs, interfaces, fields, package variables, and constants.
  • Capture receiver-aware qualified names and function signatures.
  • Emit imports, calls, containment, type references, and instantiation references when syntax makes them explicit.
  • Leave cross-file and cross-package targets unresolved through targetName.

Required changes

  • Add src/graph/extraction/languages/go.ts.
  • Register the extractor in src/graph/extraction/languages/index.ts.
  • Register .go and the grammar filename in src/graph/extraction/grammars.ts.
  • Add the grammar WASM under src/graph/wasm/ and document its source, version, and license.
  • Add a representative Go fixture and focused extractor tests.

Acceptance criteria

  • The extractor implements the frozen LanguageExtractor interface without changing it.
  • Extraction is pure, deterministic, and limited to one file.
  • Node ids use the shared line-independent generator.
  • Tests cover packages, functions, receiver methods, structs, interfaces, fields, constants, containment, imports, calls, and explicit instantiation.
  • Receiver methods have stable qualified names that distinguish their owning type.
  • Cross-file references remain unresolved for the engine to bind.
  • Unsupported or malformed syntax does not crash graph construction.
  • npm run typecheck, npm test, and npm run build pass.
  • The packed build contains the Go grammar WASM.

Out of scope

  • Implicit interface-satisfaction analysis.
  • Build-tag evaluation, module downloading, or go list execution.
  • Gin, Echo, or other framework semantics.
  • Changes to identity, reconciliation, schema, or grounding semantics.

Contributor references

Contributor workflow

git switch main
git pull
git switch -c feat/go-code-graph-extractor

Open the pull request with base branch main.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-graphWork related to the AST and Tree-sitter code graphgood first issueGood for newcomerslanguage-supportAdds or improves support for a programming languagetree-sitterTree-sitter grammars, parsing, or extraction

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions