selective

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package selective implements include/exclude filtering rules for sync paths. Rules can be loaded from a text file (Load) or constructed from YAML config (FromYAML). Both sources share identical matching semantics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

type List struct {
	Rules           []Rule
	IncludeAbs      []string // patterns anchored to root (start with "/")
	IncludeAnywhere []string // patterns matched at any depth
	ExcludeAbs      []string
	ExcludeAnywhere []string
	HasRules        bool
}

List is the compiled set of include/exclude rules.

func FromYAML added in v0.7.0

func FromYAML(include, exclude []string) *List

FromYAML constructs a List from the include/exclude slices in a YAML config block. Matching semantics are identical to Load.

func Load

func Load(path string) (*List, error)

Load reads a text sync-list file. An empty or missing path returns an empty list (no rules → allow everything). File format:

  • Lines starting with "#" or ";" are comments.
  • Lines starting with "-" or "!" are exclude rules.
  • All other non-empty lines are include rules.
  • A leading "/" anchors the pattern to the sync root; otherwise it matches at any depth.

func (*List) ShouldSync

func (l *List) ShouldSync(pathRel string, isDir bool) bool

ShouldSync reports whether pathRel should participate in sync. Safe to call on a nil receiver — returns true (allow everything). Exclude rules take priority over include rules.

type Rule

type Rule struct {
	Pattern  string
	Exclude  bool
	Absolute bool // true when the pattern starts with "/" (anchored to sync root)
}

Rule represents a single include or exclude pattern.

Jump to

Keyboard shortcuts

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