Skip to content
/ kconfig Public

A config library with environment variable possibilities

License

Notifications You must be signed in to change notification settings

krstak/kconfig

Repository files navigation

Kconfig

Yaml file my-file.yaml:

addr: ":8080"
database:
  use: true
  dialect: "postgres"
  timeout: 12
  secret: env[SECRET_PASS|super-secret]
list: 
  - "first"
  - "second"
  - "third"
gtm: "env[GTM_ENV]"

Usage:

import "github.com/krstak/kconfig"

c, err := kconfig.Load("./my-file.yaml")

// returns string ":8080"
c.Get("addr")

// returns bool true
c.GetBool("database.use")

// returns string "postgres"
c.Get("database.dialect")

// returns int 12
c.GetInt("database.timeout")

// returns slice []string{"first", "second", "third"}
c.GetSlice("list")

// returns a value of environment variable GTM_ENV as a string
c.Get("gtm")

// returns a value of environment variable SECRET_PASS as a string. If not exists, it returns a default value super-secret
c.Get("database.secret")

About

A config library with environment variable possibilities

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages