config

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2017 License: MIT Imports: 4 Imported by: 37

Documentation

Overview

Package config offers utilities for parsing a json config file. Values are read as strings, and can be fetched with Get, GetInt or GetBool. The caller is expected to parse them for more complex types.

Index

Constants

View Source
const (
	ModeDevelopment = iota
	ModeProduction
	ModeTest
)

Config modes are set when creating a new config

View Source
const (
	// DefaultPath is where our config is normally found for fragmenta apps.
	DefaultPath = "secrets/fragmenta.json"
)

Variables

This section is empty.

Functions

func Configuration

func Configuration(m int) map[string]string

Configuration returns all the configuration key/values for a given mode.

func Get

func Get(key string) string

Get returns a specific value or "" if no value

func GetBool

func GetBool(key string) bool

GetBool returns the current configuration value as bool (yes=true, no=false), or false if no value

func GetInt

func GetInt(key string) int64

GetInt returns the current configuration value as int64, or 0 if no value

func Production

func Production() bool

Production returns true if current config is production.

Types

type Config

type Config struct {
	Mode int
	// contains filtered or unexported fields
}

Config represents a set of key/value pairs for each mode of the app, production, development and test. Which set of values is used is set by Mode.

var Current *Config

Current is the current configuration object for

func New

func New() *Config

New returns a new config, which defaults to development

func (*Config) Config

func (c *Config) Config(key string) string

Config (Get) returns a specific value or "" if no value For compatability with older server config, we wrap this function Deprecated

func (*Config) Configuration

func (c *Config) Configuration(m int) map[string]string

Configuration returns all the configuration key/values for a given mode.

func (*Config) Get

func (c *Config) Get(key string) string

Get returns a specific value or "" if no value

func (*Config) GetBool

func (c *Config) GetBool(key string) bool

GetBool returns the current configuration value as bool (yes=true, no=false), or false if no value

func (*Config) GetInt

func (c *Config) GetInt(key string) int64

GetInt returns the current configuration value as int64, or 0 if no value

func (*Config) Load

func (c *Config) Load(path string) error

Load our json config file from the path

func (*Config) Production

func (c *Config) Production() bool

Production returns true if current config is production.

Jump to

Keyboard shortcuts

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