Documentation ¶
Overview ¶
Package gofig simplifies external, runtime configuration of go programs.
Index ¶
- Variables
- func FromJSON(from string) (types.Config, error)
- func New() types.Config
- func NewConfig(loadGlobalConfig, loadUserConfig bool, configName, configType string) types.Config
- func NewRegistration(name string) types.ConfigRegistration
- func Register(r types.ConfigRegistration)
- func SetGlobalConfigPath(path string)
- func SetUserConfigPath(path string)
- func ValidateYAML(r io.Reader) (map[interface{}]interface{}, error)
- func ValidateYAMLString(s string) (map[interface{}]interface{}, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// LogGetAndSet determines whether or not gettting and seetting values
// is logged.
LogGetAndSet, _ = strconv.ParseBool(os.Getenv("GOFIG_LOG_GETSET"))
// LogSecureKey determines whether or not secure key attempts are logged.
LogSecureKey, _ = strconv.ParseBool(os.Getenv("GOFIG_LOG_SECUREKEY"))
// LogFlattenEnvVars determines whether or not flattening environment
// variables is logged.
LogFlattenEnvVars, _ = strconv.ParseBool(os.Getenv("GOFIG_LOG_FLATTEN"))
// LogRegKey determines whether or not key registrations are logged.
LogRegKey, _ = strconv.ParseBool(os.Getenv("GOFIG_LOG_REGKEY"))
// DisableEnvVarSubstitution determines whether or not Gofig will replace
// environment variables with their actual values. This transformation is
// applied only to the values returned by the GetString and GetStringSlice
// functions. Environment variable substitution is not applied to config
// keys for example.
//
// New Config instances inherit this value at the time of the instance
// creation. However, this value has no effect on existing config instances.
// Those instances have a function named DisableEnvVarSubstitution that is
// able to disable/enable the feature for that instance.
DisableEnvVarSubstitution, _ = strconv.ParseBool(
os.Getenv("GOFIG_DISABLE_ENVVAR_SUBSTITUTION"))
)
Functions ¶
func NewRegistration ¶
func NewRegistration(name string) types.ConfigRegistration
NewRegistration creates a new registration with the given name.
func Register ¶
func Register(r types.ConfigRegistration)
Register registers a new configuration with the config package.
func SetGlobalConfigPath ¶
func SetGlobalConfigPath(path string)
SetGlobalConfigPath sets the path of the directory from which the global configuration file is read.
func SetUserConfigPath ¶
func SetUserConfigPath(path string)
SetUserConfigPath sets the path of the directory from which the user configuration file is read.
func ValidateYAML ¶ added in v0.1.3
ValidateYAML verifies the YAML in the stream is valid.
func ValidateYAMLString ¶ added in v0.1.3
ValidateYAMLString verifies the YAML string valid.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.