format

package
v2.1.1-0...-08c721e Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidName = errors.New("formatter name must only contain alphanumeric characters, `_` or `-`")
	// ErrCommandNotFound is returned when the Command for a Formatter is not available.
	ErrCommandNotFound = errors.New("formatter command not found in PATH")
)
View Source
var ErrFormattingFailures = errors.New("formatting failures detected")

Functions

This section is empty.

Types

type CompositeFormatter

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

CompositeFormatter handles the application of multiple Formatter instances based on global excludes and individual formatter configuration.

func NewCompositeFormatter

func NewCompositeFormatter(
	cfg *config.Config,
	statz *stats.Stats,
	batchSize int,
) (*CompositeFormatter, error)

func (*CompositeFormatter) Apply

func (c *CompositeFormatter) Apply(ctx context.Context, files []*walk.File) error

Apply applies the configured formatters to the given files.

func (*CompositeFormatter) Close

func (c *CompositeFormatter) Close(ctx context.Context) error

Close finalizes the processing of the CompositeFormatter, ensuring that any remaining batches are applied and all formatters have completed their tasks. It returns an error if any formatting failures were detected.

type Formatter

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

Formatter represents a command which should be applied to a filesystem.

func (*Formatter) Apply

func (f *Formatter) Apply(ctx context.Context, files []*walk.File) error

func (*Formatter) Executable

func (f *Formatter) Executable() string

Executable returns the path to the executable defined by Command.

func (*Formatter) Hash

func (f *Formatter) Hash(h hash.Hash) error

Hash adds this formatter's config and executable info to the config hash being created.

func (*Formatter) Name

func (f *Formatter) Name() string

func (*Formatter) Priority

func (f *Formatter) Priority() int

func (*Formatter) Wants

func (f *Formatter) Wants(file *walk.File) bool

Wants is used to determine if a Formatter wants to process a path based on it's configured Includes and Excludes patterns. Returns true if the Formatter should be applied to file, false otherwise.

Jump to

Keyboard shortcuts

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