config

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config handles loading configuration from .gonerc.yaml files.

Index

Constants

View Source
const DefaultConfigFileName = ".gonerc.yaml"

DefaultConfigFileName is the default configuration file name.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckConfig added in v0.1.3

type CheckConfig struct {
	// Concurrency is the number of concurrent workers.
	// Default: 50 (set at runtime if 0)
	Concurrency int `yaml:"concurrency"`

	// Timeout is the request timeout in seconds.
	// Default: 5 (set at runtime if 0)
	Timeout int `yaml:"timeout"`

	// Retries is the number of retry attempts for failed requests.
	// Default: 1 (set at runtime if 0)
	Retries int `yaml:"retries"`

	// Strict fails on malformed files instead of skipping them.
	// Default: false
	Strict bool `yaml:"strict"`
}

CheckConfig holds checker settings for URL validation.

type Config

type Config struct {
	// Types specifies which file types to scan.
	// Supported: md, json, yaml, toml, xml
	// If empty, defaults to ["md"] at runtime.
	Types []string `yaml:"types"`

	// Scan holds scanner configuration.
	Scan ScanConfig `yaml:"scan"`

	// Check holds checker configuration.
	Check CheckConfig `yaml:"check"`

	// Output holds output preferences.
	Output OutputConfig `yaml:"output"`

	// Ignore holds URL ignore rules (backwards compatible).
	Ignore IgnoreConfig `yaml:"ignore"`
}

Config represents the complete configuration structure.

func FindAndLoad

func FindAndLoad(startDir string) (*Config, error)

FindAndLoad searches for a config file starting from the given directory and walking up to parent directories until it finds one or reaches root. This allows project-specific configs to be found from subdirectories.

func Load

func Load() (*Config, error)

Load reads configuration from .gonerc.yaml in the current directory. Returns an empty config if the file doesn't exist (not an error). Returns an error only if the file exists but cannot be parsed.

func LoadFrom

func LoadFrom(path string) (*Config, error)

LoadFrom reads configuration from a specific path. Returns an empty config if the file doesn't exist (not an error). Returns an error only if the file exists but cannot be parsed.

func (*Config) GetShowDead added in v0.1.3

func (c *Config) GetShowDead() bool

GetShowDead returns the ShowDead value, defaulting to true if not set.

func (*Config) GetShowWarnings added in v0.1.3

func (c *Config) GetShowWarnings() bool

GetShowWarnings returns the ShowWarnings value, defaulting to true if not set.

func (*Config) HasCheckConfig added in v0.1.3

func (c *Config) HasCheckConfig() bool

HasCheckConfig returns true if any check configuration is set.

func (*Config) HasIgnoreRules added in v0.1.3

func (c *Config) HasIgnoreRules() bool

HasIgnoreRules returns true if any ignore rules are defined.

func (*Config) HasOutputConfig added in v0.1.3

func (c *Config) HasOutputConfig() bool

HasOutputConfig returns true if any output configuration is set.

func (*Config) HasScanConfig added in v0.1.3

func (c *Config) HasScanConfig() bool

HasScanConfig returns true if any scan configuration is set.

func (*Config) HasTypes added in v0.1.3

func (c *Config) HasTypes() bool

HasTypes returns true if file types are configured.

func (*Config) IsEmpty

func (c *Config) IsEmpty() bool

IsEmpty returns true if the config has no settings defined. This checks all configuration sections, not just ignore rules.

func (*Config) Merge

func (c *Config) Merge(other *Config)

Merge combines another config into this one (additive for slices). This is useful for merging CLI flags with file config.

func (*Config) Validate added in v0.1.3

func (c *Config) Validate() error

Validate checks the configuration for errors. Returns an error if any configuration value is invalid.

type IgnoreConfig

type IgnoreConfig struct {
	// Domains to ignore (automatically includes subdomains).
	// Example: "example.com" will also match "www.example.com", "api.example.com".
	Domains []string `yaml:"domains"`

	// Patterns are glob patterns for URL matching.
	// Example: "*.local/*", "*/internal/*"
	Patterns []string `yaml:"patterns"`

	// Regex are regular expression patterns for URL matching.
	// Example: ".*\\.test$", ".*/v[0-9]+/draft/.*"
	Regex []string `yaml:"regex"`
}

IgnoreConfig holds all ignore rules.

type OutputConfig added in v0.1.3

type OutputConfig struct {
	// Format specifies the default output format.
	// Valid: json, yaml, xml, junit, markdown
	// Empty means text output to stdout.
	Format string `yaml:"format"`

	// ShowAlive shows alive links in output.
	// Default: false
	ShowAlive bool `yaml:"showAlive"`

	// ShowWarnings shows warning links (redirects, blocked) in output.
	// Default: true (set at runtime)
	ShowWarnings *bool `yaml:"showWarnings"`

	// ShowDead shows dead links and errors in output.
	// Default: true (set at runtime)
	ShowDead *bool `yaml:"showDead"`

	// ShowStats shows performance statistics.
	// Default: false
	ShowStats bool `yaml:"showStats"`
}

OutputConfig holds output preferences for the check command.

type ScanConfig added in v0.1.3

type ScanConfig struct {
	// Include specifies glob patterns for paths to include.
	// If empty, all files matching the types are included.
	// Example: ["docs/**", "README.md"]
	Include []string `yaml:"include"`

	// Exclude specifies glob patterns for paths to exclude.
	// Example: ["node_modules/**", "vendor/**", "**/testdata/**"]
	Exclude []string `yaml:"exclude"`
}

ScanConfig holds scanner settings for file discovery.

Jump to

Keyboard shortcuts

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