Skip to content

a lightweight pluggable dynamic config package without useless dependencies

License

Notifications You must be signed in to change notification settings

AWaterColorPen/config

Repository files navigation

config

Go

Introduction

Config is a lightweight pluggable dynamic config package without useless dependencies. Base on forked from github.com/go-micro/go-micro/config.

Features

  • dynamic loading
  • pluggable sources
  • mergeable config
  • observe changes
  • sane defaults

Getting Started

Load and get

load config from env, flag and file.

if err := config.Load(env.NewSource()); err != nil {
    return err
}

if err := config.Load(flag.NewSource(flag.IncludeUnset(true))); err != nil {
    return err
}

configFile := "config_file.json"
if err := config.Load(file.NewSource(file.WithPath(configFile))); err != nil {
    return err
}

get config to struct

func Scan(v any, path ...string) error {
    return config.Get(path...).Scan(v)
}

License

See the License File.

About

a lightweight pluggable dynamic config package without useless dependencies

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages