Docs / languages / go · Edit on GitHub

Go

Tier 1 plugin for Go source. Covers structs, interfaces, embedding, generics, type aliases, constants, and import paths.

Implementation

Plugin cratecrates/rgctl-lang-go (GoPlugin)
Grammartree-sitter-go
Extensions.go
Discoverrgctl discover . -l go -e vendor --with-cfg
CFG / taintEnabled

Tree-sitter node kinds: function_declaration, method_declaration, type_declaration, import_declaration.

Struct embedding maps to EXTENDS; interface satisfaction maps to IMPLEMENTS. See go-language-coverage.md.

What is extracted

Nodes

  • Function, Struct, Interface, TypeAlias, Variable (consts)
  • Import — package import paths (fmt, local packages)

Edges

EdgeMeaning
CALLSFunction and method calls
IMPLEMENTSStruct satisfies interface
EXTENDSStruct embedding
ImportPackage imports

Verification

Fixturergctl-tests/ecommerce-go
Example corpusexample/kubernetes (-l go -e vendor)
Smoke scriptrgctl-tests/gql-verification-smoke/verify-extraction-gql-go.sh

GQL verification queries

Fixture probes

ProbeGQL
LF-05 implements (LfRemoteRuntime)MATCH (a:Struct)-[:IMPLEMENTS]->(b:Interface) WHERE a.name = 'LfRemoteRuntime' RETURN a,b
LF-06 embed extends (LfDerived)MATCH (a:Struct)-[:EXTENDS]->(b:Struct) WHERE a.name = 'LfDerived' RETURN a,b
LF-10 const (LfStatusPending)MATCH (n:Variable) WHERE n.name = 'LfStatusPending' RETURN n
LF-10 type alias (LfUserID)MATCH (n:TypeAlias) WHERE n.name = 'LfUserID' RETURN n
LF-16 generics (LfIdentity)MATCH (n:Function) WHERE n.name = 'LfIdentity' RETURN n
LF-16 generics (LfBox)MATCH (n:Struct) WHERE n.name = 'LfBox' RETURN n
LF-17 import (fmt)MATCH (n:Import) WHERE n.name = 'fmt' RETURN n
LF-17 import (timeutil)MATCH (n:Import) WHERE n.name = 'timeutil' RETURN n
Call resolution (CALLS)MATCH (a)-[:CALLS]->(b) RETURN a,b LIMIT 10000

Example smoke (example/kubernetes)

ProbeGQL
Import (scale)MATCH (n:Import) RETURN n LIMIT 10000
IMPLEMENTS (scale)MATCH (a)-[:IMPLEMENTS]->(b) RETURN a,b LIMIT 10000
CALLS (scale)MATCH (a)-[:CALLS]->(b) RETURN a,b LIMIT 10000

Related