config

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlobalConfigSection = "global"
)

Variables

This section is empty.

Functions

func GetCachePath added in v1.7.0

func GetCachePath(file string) string

func GetConfigPath added in v1.7.0

func GetConfigPath() (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 GetDefinitionDirs added in v1.7.0

func GetDefinitionDirs() []string

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(f string) (Config, error)

NewJSONConfig creates a new json config backed on the given file

Jump to

Keyboard shortcuts

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