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
- func Configuration(m int) map[string]string
- func Development() bool
- func Get(key string) string
- func GetBool(key string) bool
- func GetInt(key string) int64
- func Production() bool
- func Testing() bool
- type Config
- func (c *Config) Config(key string) string
- func (c *Config) Configuration(m int) map[string]string
- func (c *Config) Development() bool
- func (c *Config) Get(key string) string
- func (c *Config) GetBool(key string) bool
- func (c *Config) GetInt(key string) int64
- func (c *Config) Load(path string) error
- func (c *Config) Production() bool
- func (c *Config) Testing() bool
Constants ¶
const ( ModeDevelopment = iota ModeProduction ModeTest )
Config modes are set when creating a new config
const (
// DefaultPath is where our config is normally found for fragmenta apps.
DefaultPath = "secrets/fragmenta.json"
)
Variables ¶
This section is empty.
Functions ¶
func Configuration ¶
Configuration returns all the configuration key/values for a given mode.
func Development ¶ added in v1.5.11
func Development() bool
Development returns true if the config is Development
func GetBool ¶
GetBool returns the current configuration value as bool (yes=true, no=false), or false if no value
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 (*Config) Config ¶
Config (Get) returns a specific value or "" if no value For compatability with older server config, we wrap this function Deprecated
func (*Config) Configuration ¶
Configuration returns all the configuration key/values for a given mode.
func (*Config) Development ¶ added in v1.5.12
Development returns true if current config is development.
func (*Config) GetBool ¶
GetBool returns the current configuration value as bool (yes=true, no=false), or false if no value
func (*Config) Production ¶
Production returns true if current config is production.