Documentation
¶
Overview ¶
Package conf contains tools for managing app configuration.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶ added in v0.2.0
ConfigDir returns the path to the config dir for the app. Path precedence:
- $XDG_CONFIG_HOME/$name
- $AppData/$name (windows only)
- $HOME/.config/$name
func ConfigFile ¶ added in v0.2.0
ConfigFile returns the default config path for the app.
func ConfigFileFor ¶ added in v0.2.0
ConfigFileFor returns the config path for the app and file name.
Types ¶
type Loader ¶
Loader populates and validates config data from a file.
Example ¶
type Config struct { DatabaseURL string `default:"postgres://0.0.0.0:5432/db" validate:"required,url"` Debug bool `default:"true"` } loader := NewLoader(&Config{}, ConfigFile("termite")) config, err := loader.Load() if err != nil { panic(err) } fmt.Printf("DatabaseURL: %v, Debug: %v", config.DatabaseURL, config.Debug)
Output: DatabaseURL: postgres://0.0.0.0:5432/db, Debug: true
Click to show internal directories.
Click to hide internal directories.