Help us shape the future of Go! Take the 2026 Go Developer Survey

lang

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package lang is the facade external consumers import. It centralizes every language-specific decision in Sift: file-path role classification for ranking, smart-filter rules, and (in cgo builds) tree-sitter signature extraction. Concrete types live in the leaf types package, global tables in registry, and the signature engine in the cgo-only signature subpackage; language drivers register themselves via init() and are pulled in by imports.go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeclMap

func DeclMap(tags ...string) map[string]bool

DeclMap builds a lookup set of AST node types for a SignatureSpec.

func HasImportScanner added in v1.5.0

func HasImportScanner(path string) bool

HasImportScanner reports whether the language for path extracts imports.

func ImportExtensions added in v1.5.0

func ImportExtensions() []string

ImportExtensions lists the sorted extensions of import-scanning languages.

func Imports

func Imports(path, moduleRoot string, content []byte) []string

Imports returns the import targets referenced by a file, resolved to repo-relative path prefixes. Paths whose language has no ImportScanner contribute no fan-in.

func Register

func Register(l Language)

Register adds a language to the global registry.

func ResolveImports added in v1.3.0

func ResolveImports(path, moduleRoot string, content []byte, exists func(string) bool) []string

ResolveImports returns the import targets referenced by a file as confirmed, existing repo-relative file paths. Drivers implementing ImportResolver commit to real files; all other paths fall back to generic prefix expansion. exists reports whether a candidate path was collected.

func ShouldSkipSmart

func ShouldSkipSmart(path, filename string, content []byte) (bool, string)

ShouldSkipSmart reports whether any registered language's smart rules skip the file.

Types

type Classification

type Classification = types.Classification

Classification is a soft selection signal for ranking and budgeting.

func Classify

func Classify(path string) Classification

Classify applies shared conventions and then the language driver rules.

type ID

type ID = types.ID

ID uniquely identifies a supported language.

const (
	Go         ID = types.Go
	JavaScript ID = types.JavaScript
	TypeScript ID = types.TypeScript
	TSX        ID = types.TSX
	Python     ID = types.Python
	Rust       ID = types.Rust
	Java       ID = types.Java
	Kotlin     ID = types.Kotlin
	CSharp     ID = types.CSharp
	Cpp        ID = types.Cpp
	Ruby       ID = types.Ruby
	PHP        ID = types.PHP
	Swift      ID = types.Swift
	Dart       ID = types.Dart
	Zig        ID = types.Zig
	Other      ID = types.Other
)

Language IDs.

type Language

type Language = types.Language

Language is the contract every driver implements.

func ByID

func ByID(id ID) (Language, bool)

ByID returns the language registered under id.

func ForPath

func ForPath(path string) (Language, bool)

ForPath resolves the language for a file by extension.

type Role

type Role = types.Role

Role describes the likely architecture purpose of a file.

const (
	RoleUnknown    Role = types.RoleUnknown
	RoleEntrypoint Role = types.RoleEntrypoint
	RoleAPI        Role = types.RoleAPI
	RoleImpl       Role = types.RoleImpl
	RoleTest       Role = types.RoleTest
	RoleFixture    Role = types.RoleFixture
	RoleMock       Role = types.RoleMock
	RoleConfig     Role = types.RoleConfig
	RoleSchema     Role = types.RoleSchema
	RoleDocs       Role = types.RoleDocs
	RoleGenerated  Role = types.RoleGenerated
	RoleExample    Role = types.RoleExample
	RoleVendor     Role = types.RoleVendor
)

File roles.

type SignatureResolver

type SignatureResolver = types.SignatureResolver

SignatureResolver is an optional capability of a Language that maps a path to the signature registry ID for it.

Directories

Path Synopsis
Package registry owns the global language lookup tables and the shared path-convention rules.
Package registry owns the global language lookup tables and the shared path-convention rules.
Package signature owns the tree-sitter signature engine: per-language SignatureSpec registration and a pooled parser engine that reduces source to declaration signatures.
Package signature owns the tree-sitter signature engine: per-language SignatureSpec registration and a pooled parser engine that reduces source to declaration signatures.
Package types defines the core language contracts shared by every driver and the registry.
Package types defines the core language contracts shared by every driver and the registry.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL