Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.02 KB

README.md

File metadata and controls

49 lines (34 loc) · 1.02 KB

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.