Skip to content

library to easily write or read configs, supports json, toml and yaml

Notifications You must be signed in to change notification settings

RestartFU/gophig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started

Gophig may be imported using go get:

go get github.com/restartfu/gophig

Usage

You may create a new *Gophig:

type foo struct{
   foo string `toml:"foo"`
   bar string `toml:"bar"`
}

g := gophig.NewGophig("./config", "toml", 0777)

Then you may use the method SetConf(v interface{}):

myFoo := &foo{foo: "foo", bar: "bar"}

if err := g.SetConf(myFoo);err != nil{
   log.Fatalln(err)
}

// Output file content:
// ./config.toml
/* 
   foo = "foo"
   bar = "bar"
*/

Or the method GetConf(v interface{}):

// If we assume that the output file content is the same as the example up there:

var myFooStruct *foo

if err := g.GetConf(foo);err != nil{
   log.Fatalln(err)
}

log.Println(*foo)

// Output:
/* 
   {foo: "foo", bar: "bar"}
*/

About

library to easily write or read configs, supports json, toml and yaml

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages