config

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlobalConfigSection = "global"
)

Variables

This section is empty.

Functions

func DefaultDir

func DefaultDir() (string, error)

func Dirs

func Dirs() ([]string, error)

func Find

func Find(filename string, dirs []string) (string, error)

func GetDefault

func GetDefault(section, key, defaultVal string, c Config) (string, error)

GetDefault gets a value from the config, with a default if it doesn't exist

func GetGlobalConfig

func GetGlobalConfig(key, defaultVal string, c Config) (string, error)

GetGlobalConfig gets a value from the Environment, the global config or a default fallback value if neither exists. If the key is "test", "CARDIGANN_TEST" is checked in the environment

func IsSectionEnabled

func IsSectionEnabled(section string, c Config) bool

IsSectionEnabled returns true if a section has an enabled=true

Types

type ArrayConfig

type ArrayConfig map[string]map[string]string

func (ArrayConfig) Get

func (a ArrayConfig) Get(section, key string) (string, bool, error)

func (ArrayConfig) Section

func (a ArrayConfig) Section(section string) (map[string]string, error)

func (ArrayConfig) Sections

func (a ArrayConfig) Sections() ([]string, error)

func (ArrayConfig) Set

func (a ArrayConfig) Set(section, key, value string) error

type Config

type Config interface {
	Get(section, key string) (string, bool, error)
	Set(section, key, value string) error
	Sections() ([]string, error)
	Section(section string) (map[string]string, error)
}

func NewJSONConfig

func NewJSONConfig() (Config, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL