modulepackage
0.0.0-20210923073057-74d169b75369
Repository: https://github.com/adamhutchison/flux-config.git
Documentation: pkg.go.dev
# README
Flux Config
The Flux Config package is designed to handle the loading and retrival of configurations values from within the Flux framework.
Flux config will load all values set in the .env
file located in the root of the project aswell as any values contained within a config/config.yaml
file.
install flex config using go get github.com/AdamHutchison/flux-config
.
Loading and Retrieving Config Values
if we have a config/config.yaml
containing the following:
app:
name: "Flux App"
Then we can load and access the values like this:
import(
config "github.com/AdamHutchison/flux-config"
)
func main() {
config.Load()
name := config.Get("app.name")
}
Accessing Env values
After config.Load()
has been called, Env values located in the .env
can be accessed using os.Getenv("ENV_VARIABLE_NAME")
Setting Config Values Using Env Variables
Env variables may be used in the config.yaml
file using the ${ENV_VARIABLE_NAME}
syntax:
.env
APP_NAME="Flux App"
config.yaml
app:
name: ${APP_NAME}