mirror of
https://github.com/spf13/viper
synced 2025-05-07 20:57:18 +00:00
Viper commit
This commit is contained in:
parent
d80342619e
commit
9f79234f5e
1 changed files with 20 additions and 20 deletions
40
viper.go
40
viper.go
|
@ -23,6 +23,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
@ -31,7 +32,6 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"errors"
|
|
||||||
|
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
@ -1536,15 +1536,15 @@ func (v *Viper) getRemoteConfig(provider RemoteProvider) (map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the First Found remote configuration
|
// Retrieve the First Found remote configuration
|
||||||
func (v *Viper)GetRemoteConf() (io.Reader, error) {
|
func (v *Viper) GetRemoteConf() (io.Reader, error) {
|
||||||
for _, rp := range v.remoteProviders {
|
for _, rp := range v.remoteProviders {
|
||||||
reader, err := RemoteConfig.Get(rp)
|
reader, err := RemoteConfig.Get(rp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return reader, nil
|
return reader, nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("Did not find Remote config")
|
return nil, errors.New("Did not find Remote config")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the first found remote configuration.
|
// Retrieve the first found remote configuration.
|
||||||
|
@ -1716,7 +1716,7 @@ func (v *Viper) SetConfigType(in string) {
|
||||||
|
|
||||||
// GetConfigType gets the type of configuration file used by current viper object
|
// GetConfigType gets the type of configuration file used by current viper object
|
||||||
func (v *Viper) GetConfigType() string {
|
func (v *Viper) GetConfigType() string {
|
||||||
return v.getConfigType()
|
return v.getConfigType()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Viper) getConfigType() string {
|
func (v *Viper) getConfigType() string {
|
||||||
|
@ -1738,16 +1738,16 @@ func (v *Viper) getConfigType() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAppConfigFile gets the filename of local configuration file used
|
// GetAppConfigFile gets the filename of local configuration file used
|
||||||
func (v *Viper) GetAppConfigFile() (string, error) {
|
func (v *Viper) GetAppConfigFile() (string, error) {
|
||||||
if v.configFile == "" {
|
if v.configFile == "" {
|
||||||
cf, err := v.findConfigFile()
|
cf, err := v.findConfigFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
v.configFile = cf
|
v.configFile = cf
|
||||||
}
|
}
|
||||||
return v.configFile, nil
|
return v.configFile, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Viper) getConfigFile() (string, error) {
|
func (v *Viper) getConfigFile() (string, error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue