Skip to content
Branch: master
Go to file
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

README.md

go-conf

nconf inspired configuration for go

Simple usage:

package main

import (
	"fmt"
	"github.com/abhiagarwal/goconf"
)

func main() {
	var parsedData map[string]interface{}
	parsedData = make(map[string]interface{})
	parsedData = goconf.Parse("go.conf")

	fmt.Println(parsedData)
}

where go.conf is:

HELLO_KEY = 4
API_NESS = 128328
GOOGLIE = string

A simple Twitter API usage:

package main

import (
	"fmt"
	anaconda "github.com/ChimeraCoder/anaconda"
	"github.com/abhiagarwal/goconf"
	"net/url"
)

func getConfiguration() map[string]interface{} {
	var parsedData map[string]interface{}
	parsedData = make(map[string]interface{})
	parsedData = goconf.Parse("twitter.conf")
	return parsedData
}

func main() {
	var configuration map[string]interface{}
	configuration = make(map[string]interface{})
	configuration = getConfiguration()

	ConsumerKey, _ := configuration["ConsumerKey"].(string)
	ConsumerSecret, _ := configuration["ConsumerSecret"].(string)
	AccessToken, _ := configuration["AccessToken"].(string)
	AccessTokenSecret, _ := configuration["AccessTokenSecret"].(string)

	anaconda.SetConsumerKey(ConsumerKey)
	anaconda.SetConsumerSecret(ConsumerSecret)
	api := anaconda.NewTwitterApi(AccessToken, AccessTokenSecret)

	v := url.Values{}
	v.Set("count", "100")

	searchResult, _ := api.GetSearch("nyu", v)
	for _, tweet := range searchResult {
		fmt.Println(tweet.Text)
	}
}

where twitter.conf is:

ConsumerKey = 
ConsumerSecret = 
AccessToken = 
AccessTokenSecret = 

About

very simple configuration file parser that is nconf inspired

Resources

License

Releases

No releases published

Languages

You can’t perform that action at this time.