Unified configuration loading for the CLI, LSP and library defaults.
Import path: github.com/ajitpratap0/GoSQLX/pkg/config (pkg.go.dev)
Part of the GoSQLX API reference.
The configuration package provides unified configuration management for GoSQLX.
type Config struct {
Linter LinterConfig // Linter settings
Format FormatConfig // Formatting settings
Dialect string // SQL dialect (postgresql, mysql, sqlite, etc.)
MaxDepth int // Maximum parsing depth
}type LinterConfig struct {
Enabled bool // Enable linting
Rules map[string]bool // Rule enablement (L001, L002, etc.)
Severity map[string]string // Rule severity overrides
}type FormatConfig struct {
IndentSize int // Indent size (default: 2)
UppercaseKeywords bool // Uppercase SQL keywords
InsertFinalNewline bool // Insert newline at end of file
}Load configuration from file (.gosqlx.yml).
cfg, err := config.Load(".gosqlx.yml")
if err != nil {
log.Fatal(err)
}Load configuration from environment variables.
cfg := config.LoadFromEnv()Get default configuration.
cfg := config.Default()# .gosqlx.yml
dialect: postgresql
linter:
enabled: true
rules:
L001: true # Trailing whitespace
L002: true # Mixed tabs/spaces
L003: true # Consecutive blank lines
L004: true # Indentation depth
L005: true # Line length
L006: false # Column alignment (disabled)
L007: true # Keyword case
L008: false # Comma placement (disabled)
L009: true # Aliasing consistency
L010: true # Redundant whitespace
severity:
L007: error # Override: keyword case is error instead of warning
format:
indent_size: 2
uppercase_keywords: true
insert_final_newline: true
max_depth: 100Caching:
- Thread-safe cache with automatic invalidation on file modification