Skip to content

lwlee2608/adder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adder

A lightweight configuration library for Go, inspired by viper.

Adder reads YAML config files and unmarshals them into Go structs, with support for environment variable overrides.

Installation

go get github.com/lwlee2608/adder

Quick Start

# application.yaml
server:
  host: localhost
  port: 8080
type Config struct {
    Server struct {
        Host string
        Port uint
    }
}

adder.SetConfigName("application")
adder.AddConfigPath(".")
adder.SetConfigType("yaml")

if err := adder.ReadInConfig(); err != nil {
    panic(err)
}

var config Config
if err := adder.Unmarshal(&config); err != nil {
    panic(err)
}

Features

  • Case-insensitive YAML key matching
  • YAML configuration with multiple search paths
  • Automatic environment variable overrides via AutomaticEnv()
  • Explicit env var binding via BindEnv()
  • mapstructure struct tags for custom field mapping
  • Singleton and instance-based usage

Examples

See the example/ directory:

  • basic — Load config from a YAML file
  • env-override — Override config values with environment variables
  • bind-env — Bind config keys to specific env var names

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages