Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eraclitux/conf
Configuration file and cli arguments parser for Go
https://github.com/eraclitux/conf
cli configuration golang-package
Last synced: 22 days ago
JSON representation
Configuration file and cli arguments parser for Go
- Host: GitHub
- URL: https://github.com/eraclitux/conf
- Owner: eraclitux
- License: mit
- Created: 2014-06-16T21:33:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-02-05T17:53:48.000Z (about 7 years ago)
- Last Synced: 2024-11-20T02:29:43.455Z (3 months ago)
- Topics: cli, configuration, golang-package
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
====
conf
====|image0|_ |image1|_ |image2|_
.. |image0| image:: https://godoc.org/github.com/eraclitux/conf?status.svg
.. _image0: https://godoc.org/github.com/eraclitux/conf.. |image1| image:: https://travis-ci.org/eraclitux/conf.svg?branch=master
.. _image1: https://travis-ci.org/eraclitux/conf.. |image2| image:: https://goreportcard.com/badge/github.com/eraclitux/conf
.. _image2: https://goreportcard.com/report/github.com/eraclitux/conf.. contents::
Intro
=====
A go package for configuration parsing. Automagically populates a configuration ``struct`` using configuration files & command line arguments.It aims to be modular and easily extendible to support other formats. Only INI format supported for now.
Usage and examples
==================
An example of utilization::type myConf struct {
Address string
Port string
// A command line flag "-users", which expects an int value,
// will be created.
// Same key name will be searched in configuration file.
NumberOfUsers int `conf:"users,number of users,"`
Daemon bool
Message string
}func Example() {
// To create a dafault value for a flag
// assign it when instantiate the conf struct.
c := myConf{Message: "A default value"}
conf.Path = "test_data/one.ini"
err := conf.Parse(&c)
if err != nil {
log.Fatal("Unable to parse configuration", err)
}
fmt.Println("address:", c.Address)
fmt.Println("port:", c.Port)
fmt.Println("number of users:", c.NumberOfUsers)
}See the flag arguments that are automagically created::
go run main.go -h
See `godocs `_ for examples and documentation.
Pull requests that add new tests, features or fixes are welcome, encouraged, and credited.