Beispiel #1
0
func ExampleConfig_Load() {
	conf := config.NewConfig("myapp")
	conf.Save("logins", "*****@*****.**", "12345")
	password, _ := conf.Load("logins", "*****@*****.**")
	fmt.Println(password)
	// Output: 12345
}
Beispiel #2
0
func ExampleConfig_List() {
	conf := config.NewConfig("myapp")
	conf.Save("logins", "*****@*****.**", "12345")
	conf.Save("logins", "*****@*****.**", "12345")
	logins, _ := conf.List("logins")
	fmt.Println(logins)
	// Output: [[email protected] [email protected]]
}
Beispiel #3
0
package main

import (
	"github.com/ddollar/config"
	"os"
	"path/filepath"
	"strings"
	//"fmt"
)

var Config = config.NewConfig("force")

func GetSourceDir() (src string, err error) {
	// Last element is default
	var sourceDirs = []string{
		//"src",
		"metadata",
	}

	wd, err := os.Getwd()

	err = nil
	for _, src = range sourceDirs {
		if strings.Contains(wd, src) {
			// our working directory contains a src dir above us, we need to move up the file syste
			nsrc := wd
			for {
				nsrc = filepath.Dir(nsrc)
				if filepath.Base(nsrc) == src {
					src = nsrc
					return
Beispiel #4
0
package main

import (
	"github.com/bmizerany/assert"
	"github.com/ddollar/config"
	"testing"
)

var TestConfig = config.NewConfig("force")

// test that SetActiveLogin in turn sets the "current account"
func TestSetActiveLogin(t *testing.T) {
	SetActiveLogin("clint")
	account, _ := TestConfig.Load("current", "account")
	assert.Equal(t, account, "clint")
}
Beispiel #5
0
func ExampleNewConfig() {
	conf := config.NewConfig("myapp")
	fmt.Println(conf.Base)
	// Output: myapp
}