Documentation
¶
Overview ¶
Package filterlist implements the --files-from JSON include/exclude allowlist for ckv build. Supplied at the CLI as a path to a JSON file:
{
"include": ["consensus/wbft/**", "core/txpool/*.go"],
"exclude": ["**/testdata/**", "**/*_test.go"]
}
Patterns use doublestar semantics: `**` matches any number of path segments (including zero). Both fields are optional — an empty include list means "every discovered file is eligible" and the exclude list still trims unwanted matches.
The JSON schema is intentionally identical to the one in the sibling code-knowledge-graph repo (internal/filterlist/filterlist.go) so a single file-list JSON works for both ckg and ckv.
Rationale: ckv already has a denylist (--exclude / .ckvignore). This package provides the orthogonal allowlist: "I want ONLY these files." Unlike GoBuildFiles (which is Go-only and driven by go/packages), this filter applies to ALL languages (Go, TypeScript, Solidity, JavaScript, Markdown) before any per-language handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilterList ¶
FilterList holds the parsed include/exclude rules.
func Load ¶
func Load(path string) (*FilterList, error)
Load reads and parses the JSON file at path. Returns a nil filter (and nil error) when path is empty — callers can treat nil as "no allowlist".
func (*FilterList) Allow ¶
func (f *FilterList) Allow(relPath string) bool
Allow reports whether relPath (slash-separated, relative to srcRoot) passes the filter. Decision rule:
- exclude match → reject (exclude trumps include)
- include empty → accept (nil filter is also accepted)
- include match → accept
- otherwise → reject
func (*FilterList) FilterPaths ¶
func (f *FilterList) FilterPaths(paths []string) []string
FilterPaths returns the subset of paths that f.Allow accepts. A nil filter returns paths unchanged (zero allocation).