Skip to content

Go (1.18-1.23+)

  • Language Standard: Go 1.18 through 1.23+
  • Recognized Extensions: .go
  • Stdin Flag: -l go
  • Measured Throughput (v0.4.0): 95.4 us ByteString SIMD Go BS lexer (Small ~85 LOC, RQ7); 1.83 ms full Go pipeline (~100 LOC, RQ2); 33,956 LOC/s cold and 15.18× warm speedup on 994-file prometheus

2. Supported Constructs & Package Directory Merging

Section titled “2. Supported Constructs & Package Directory Merging”

Canontra’s pure-Haskell ByteString-native Go frontend (Canontra.Parser.Go) supports:

  • Package Directory Merging (WholeRepoGraph): .go files sharing a package directory merge into one package symbol namespace for F_WCG and F_WDF resolution.
  • Go 1.21+ Builtins: Recognizes min, max, and clear calls cleanly during call-graph and data-flow analysis.
  • Generics & Tilde Constraint Sets (~T): Type parameter lists (func Map[K comparable, V any](...)) and union/approximation constraints (~int | ~float64).
  • Concurrency & Control Flow: Goroutines (go fn()), channel sends/receives, select statements, switch/type switch, defer blocks, for/range loops, and factored import/type/const/var blocks.
  • Declarations & Receivers: Package declarations, functions, methods with pointer/value receivers, struct types, and interface method sets.

3. Language-Specific Alpha Scoping & F_T Rules

Section titled “3. Language-Specific Alpha Scoping & F_T Rules”
  • Short Variable Redeclaration (canonicalizeAlphaModuleForLang): Honors Go’s := block-scoping and multi-assignment redeclaration rules (reusing an existing variable in the same block vs. allocating a fresh @v<depth>.<ordinal> in a nested block).
  • Export Visibility & ABI Scalar Widths (F2 / F_T): Capitalized exported functions, struct fields, and interface methods govern F2 and F_T; fixed-width scalars (int32 vs int64, uint32 vs uint64, float32 vs float64) remain strictly distinct in F_T.
  • Constraint Sorting & Recursive Struct Breaker: Union constraints (~int | ~float64 vs ~float64 | ~int) flatten and sort canonically in F_T, type parameters map to α0, α1, and self-referential structs terminate cleanly with TypeRecVar 0.

4. Unsupported & Conservative-Fallback Constructs

Section titled “4. Unsupported & Conservative-Fallback Constructs”
  • Cgo (import "C"): Inline C preamble comments and C.* symbols are hashed as external dependency tokens in F3 and F_CG; Canontra never runs a C compiler or parses C headers.
  • //go:generate Directives: Treated as comments until generated .go files exist on disk.
  • reflect Package Dispatch: Dynamic method lookups and struct tag reflection (reflect.ValueOf) do not synthesize speculative call edges in F_WCG.