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

filterlist

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package filterlist implements the --files-from JSON include/exclude filter for ckg build. Supplied at the CLI as a path to a JSON file:

{
  "include": ["internal/**/*.go", "cmd/ckg/*.go"],
  "exclude": ["**/testdata/**", "**/*_test.go"]
}

Patterns use Go's filepath.Match doublestar extension via the bundled matcher: `**` matches any number of path segments. Both fields are optional — empty include means "every discovered file is eligible" and the exclude list still trims unwanted matches.

Rationale: ckg already has heuristic discovery (detect.Walk for TS/Sol, go/packages.Load for Go) and a .ckgignore for project-wide excludes. --files-from is the explicit operator override for "I have my own build list — use exactly these files." This is the entry point for future build-system integration (tsconfig include/exclude, hardhat sources, `go list -f '{{.GoFiles}}'`) which all produce a file list as output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterList

type FilterList struct {
	Include []string `json:"include"`
	Exclude []string `json:"exclude"`
}

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 filter".

func (*FilterList) Allow

func (f *FilterList) Allow(relPath string) bool

Allow reports whether relPath (slash-separated, relative to srcRoot) passes the filter. Decision rule:

  1. exclude match → reject (exclude trumps include)
  2. include empty → accept
  3. include match → accept
  4. otherwise → reject

func (*FilterList) FilterPaths

func (f *FilterList) FilterPaths(paths []string) []string

FilterPaths returns the subset of paths that f.Allow accepts. nil filter returns paths unchanged (zero allocation).

Jump to

Keyboard shortcuts

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