An open API service indexing awesome lists of open source software.

https://github.com/awatercolorpen/config

a lightweight pluggable dynamic config package without useless dependencies
https://github.com/awatercolorpen/config

config dynamic-loading golang lightweight pluggable

Last synced: 21 days ago
JSON representation

a lightweight pluggable dynamic config package without useless dependencies

Awesome Lists containing this project

README

        

# config

[![Go](https://github.com/AWaterColorPen/config/actions/workflows/go.yml/badge.svg)](https://github.com/AWaterColorPen/config/actions/workflows/go.yml)

## Introduction

Config is a lightweight pluggable dynamic config package without useless dependencies.
Base on forked from [github.com/go-micro/go-micro/config](https://github.com/go-micro/go-micro/tree/master/config).

## Features

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

## Getting Started

### Load and get

load config from `env`, `flag` and `file`.

```golang
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

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

## License

See the [License File](./LICENSE).