source

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = NewRegistry()

Default is the registry with built-in sources registered.

Functions

This section is empty.

Types

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maps kind identifiers to factory functions. Built-ins are registered in init(); external code can register additional kinds before invoking the validate command.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Kinds

func (r *Registry) Kinds() []string

Kinds returns the registered kind identifiers in sorted order, for use in help text and error messages.

func (*Registry) Open

func (r *Registry) Open(kind string, args []string) (Source, error)

Open constructs a source by kind with the provided args. The first arg is treated as the primary argument (path, URL, etc.); subsequent args are plugin-specific.

func (*Registry) Register

func (r *Registry) Register(kind string, factory func(args []string) (Source, error))

Register installs a factory under the given kind identifier. Empty kind or nil factory panics — these are programming errors, not runtime conditions.

type SliceSource

type SliceSource struct {
	// contains filtered or unexported fields
}

SliceSource is a small adapter for tests and for callers that already have keys in memory. Not registered by default.

func NewSliceSource

func NewSliceSource(keys ...string) *SliceSource

func (*SliceSource) Close

func (s *SliceSource) Close() error

func (*SliceSource) Name

func (s *SliceSource) Name() string

func (*SliceSource) Next

func (s *SliceSource) Next(ctx context.Context) (string, error)

func (*SliceSource) Total

func (s *SliceSource) Total() int

type Source

type Source interface {
	// Name returns the kind identifier (e.g. "file", "stdin").
	Name() string
	// Next returns the next key. io.EOF signals end-of-stream.
	Next(ctx context.Context) (string, error)
	// Total reports an estimate of total keys if known, or 0 if streaming.
	Total() int
	// Close releases any underlying resources.
	Close() error
}

Source produces a stream of keys to validate. Implementations must be safe to call Next() concurrently; the validate pipeline pulls from a single goroutine so concurrency is not strictly required.

Jump to

Keyboard shortcuts

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