mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Added more API documentation
This commit is contained in:
parent
2bc3c74277
commit
f7b08da064
8 changed files with 150 additions and 90 deletions
|
|
@ -7,15 +7,19 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// LoadConfig() will load a YAML config file at the specified path. There are some general
|
||||
// considerations about how this is done with spf13/viper:
|
||||
//
|
||||
// 1. There are intentionally no search paths set, so config path has to be set explicitly
|
||||
// 2. No data will be written to the config file from the tool
|
||||
// 3. Parameters passed as CLI flags and envirnoment variables should always have
|
||||
// precedence over values set in the config.
|
||||
func LoadConfig(path string) error {
|
||||
dir, filename, ext := util.SplitPathForViper(path)
|
||||
// fmt.Printf("dir: %s\nfilename: %s\nextension: %s\n", dir, filename, ext)
|
||||
viper.AddConfigPath(dir)
|
||||
viper.SetConfigName(filename)
|
||||
viper.SetConfigType(ext)
|
||||
// ...no search paths set intentionally, so config has to be set explicitly
|
||||
// ...also, the config file will not save anything
|
||||
// ...and finally, parameters passed to CLI have precedence over config values
|
||||
viper.AutomaticEnv()
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue