Skip to content

Jel1ySpot/conic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is in early developing. We need your help to make it perfect

conic


Another easy way for configuration

Install

go get -u github.com/Jel1ySpot/conic

How conic works?

By binding variable and configuration, you can access and change the configuration in a easy way.

Configuration (usually a file) <=> Go Variable

Getting start

Quick start

package main

import (
    "fmt"
    "github.com/Jel1ySpot/conic"
)

type Config struct {
    Name string `json:"name"`
    Age  int    `json:"age"`
}

func main() {
    config := Config{}
    
    // Binding
    conic.BindRef("", &config)

    // Read configuration file
    conic.SetConfigFile("config.json")
    conic.ReadConfig()
    conic.WatchConfig()
    /* config.json
       {
         "name": "alex",
         "age": 21
       }
    */

    fmt.Printf("&v", config)
    
    // Change value
    config.Name = "Richard"
    config.Age += 7
    conic.WriteConfig()
    /* config.json
    {
      "name": "Richard",
      "age": 28
    }
    */
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages