Documentation
¶
Overview ¶
Package gonfigure helps creating configuration structs.
The intended usage would be a simple struct that calls Value() on a fields initialization. E.g.
var portProperty = gonfigure.NewEnvProperty("PORT", "8080") var domainProperty = gonfigure.NewRequiredEnvProperty("DOMAIN") type Config struct { Port string Domain string } func NewConfig() Config { return Config{ Port: portProperty.Value(), // If the $DOMAIN env variable is not set, this call will panic Domain: domainProperty.Value(), } }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Property ¶
type Property interface {
Value() string
}
Property can be used to fetch default values for configuration properties.
func NewEnvProperty ¶
NewEnvProperty returns a Property that gets its value from the specified environment variable. If the environment vatiable is not set the fallback value will be used instead
func NewRequiredEnvProperty ¶
NewRequiredEnvProperty returns a Property that gets its value from the specified environment variable. Panics if the variable is not set.
Click to show internal directories.
Click to hide internal directories.