Skip to content

Latest commit

 

History

History
99 lines (77 loc) · 2.2 KB

config.md

File metadata and controls

99 lines (77 loc) · 2.2 KB

config package

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.

Types

Config

type Config struct {
    Linter   LinterConfig   // Linter settings
    Format   FormatConfig   // Formatting settings
    Dialect  string         // SQL dialect (postgresql, mysql, sqlite, etc.)
    MaxDepth int            // Maximum parsing depth
}

LinterConfig

type LinterConfig struct {
    Enabled bool              // Enable linting
    Rules   map[string]bool   // Rule enablement (L001, L002, etc.)
    Severity map[string]string // Rule severity overrides
}

FormatConfig

type FormatConfig struct {
    IndentSize        int  // Indent size (default: 2)
    UppercaseKeywords bool // Uppercase SQL keywords
    InsertFinalNewline bool // Insert newline at end of file
}

Functions

Load(filename string) (*Config, error)

Load configuration from file (.gosqlx.yml).

cfg, err := config.Load(".gosqlx.yml")
if err != nil {
    log.Fatal(err)
}

LoadFromEnv() *Config

Load configuration from environment variables.

cfg := config.LoadFromEnv()

Default() *Config

Get default configuration.

cfg := config.Default()

Configuration File Example

# .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: 100

Caching:

  • Thread-safe cache with automatic invalidation on file modification