Readme.md 1.8 KB
Newer Older
1
# Configurator
Roy Ragsdale's avatar
Roy Ragsdale committed
2

Roy Ragsdale's avatar
Roy Ragsdale committed
3
[![pipeline status][pimg]][plnk] [![coverage report][cimg]][clnk] [![Go Report Card][rimg]][rlnk] [![GoDoc][dimg]][dlnk]
4

5
6
A simple, highly opinionated, library to load a configuration. Heavily based on
the recommendations from Kelsey Hightower's [12-fractured-apps][kh] post.  This
7
8
extends his library [envconfig][e] to add in the ability to also load from
a yaml configuration file.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25


This library has only one public function which expects to be passed a struct
specifying the configuration and containing the default values.

```
func LoadConfig(config interface{}, prefix string) error
```

This will the over-ride the defaults by loading with the following order (from
lowest priority to highest):

1. configuration file (yaml)
  - from `config.yml` (the library default, lowest priority)
  - from value specified by the CONFIG environment variable (with prefixing as
    described below)
2. environment variables
26
27
  - optionally specify a prefix, eg: `app` will result in `APP_VAR`
  - for more information on using environment variables see the `envconfig`
28
29
30
31
32
33
    [usage][u]

[kh]:https://medium.com/@kelseyhightower/12-fractured-apps-1080c73d481c
[e]:https://github.com/kelseyhightower/envconfig
[u]:https://github.com/kelseyhightower/envconfig#usage

34
35
36
37
38
39
40
41
42
[pimg]:https://gitlab.com/royragsdale/configurator/badges/master/pipeline.svg
[plnk]:https://gitlab.com/royragsdale/configurator/commits/master

[cimg]:https://gitlab.com/royragsdale/configurator/badges/master/coverage.svg
[clnk]:https://gitlab.com/royragsdale/configurator/commits/master

[rimg]:https://goreportcard.com/badge/gitlab.com/royragsdale/configurator
[rlnk]:https://goreportcard.com/report/gitlab.com/royragsdale/configurator

Roy Ragsdale's avatar
Roy Ragsdale committed
43
44
45
[dimg]:https://godoc.org/gitlab.com/royragsdale/configurator?status.svg
[dlnk]:https://godoc.org/gitlab.com/royragsdale/configurator

Roy Ragsdale's avatar
Roy Ragsdale committed
46