Skip to content

Repository files navigation

goconf

GoDocBuild StatusCoverage StatusGo Report Card

Combine yaml and environment config

Features

Installation

go get gopkg.in/plimble/goconf.v1

Env format

typeSampleAstruct {
Astring// PREFIX_ACamelCasebool// PREFIX_CAMELCASEManualOverride1string`envconfig:"manual_override_1"`// PREFIX_MANUAL_OVERRIDE_1SplitWord1string`split_words:"true"`// SPLIT_WORD1IDstring// PREFIX_IDDefaultValuestring`envconfig:"DEFAULT_VALUE"`// PREFIX_DEFAULT_VALUE
}

Yaml format

typeSampleAstruct {
Astring`json:"abc"`// abcCamelCasebool`yaml:"cc"`// ccManualOverride1string// manualoverride1SplitWord1string// splitword1IDstring// idDefaultValuestring// defaultvalue
}

Example

typeSamplestruct {
Valuestring
}
varbytes=`value: v1`sample:=&Sample{}
// Parse Order: yaml bytes -> yaml file -> enverr=goconf.Parse(sample,
WithEnv("prefix"),
WithYamlFromBytes(bytes),
WithYaml("path.yml"),
)

Watch Config

goconf.WatchYamlFile("path.yml", sample, func() error {
fmt.Println("event on chane")
returnnil
})
// or ignore eventgoconf.WatchYamlFile("path.yml", sample, nil)

About

Go config library

Topics

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages