Skip to content

stvp/go-toml-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-toml-config

Build Status

go-toml-config is a simple TOML-based configuration package for Golang apps that allows you to easily load configuration files and set defaults. It's a simple wrapper around flag.FlagSet, so you can use it in pretty much the same exact way.

API documentation

Example

With my_app.conf:

country = "USA"

[atlanta]
enabled = true
population = 432427
temperature = 99.6

Use:

import "github.com/stvp/go-toml-config"

var (
  country            = config.String("country", "Unknown")
  atlantaEnabled     = config.Bool("atlanta.enabled", false)
  alantaPopulation   = config.Int("atlanta.population", 0)
  atlantaTemperature = config.Float64("atlanta.temperature", 0)
)

func main() {
  config.Parse("/path/to/my_app.conf")
}

You can also create different ConfigSets to manage different logical groupings of config variables:

networkConfig = config.NewConfigSet("network settings", config.ExitOnError)
networkConfig.String("host", "localhost")
networkConfig.Int("port", 8080)
networkConfig.Parse("/path/to/network.conf")

Contributors

Thanks all!

  • @tysonmote
  • @matrixik
  • @fwang2002
  • @shanks
  • @xboston
  • @tgulacsi

About

TOML-based config for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages