mirror of
https://github.com/spf13/viper
synced 2024-12-22 11:37:02 +00:00
Run gofmt on all existing code
Also: * Add check to .travis.yml that verifies that all code is gofmt-compliant * Touch up some newlines See #351
This commit is contained in:
parent
f257d19100
commit
8ac2e2e20f
5 changed files with 8 additions and 13 deletions
|
@ -17,6 +17,7 @@ matrix:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- go install ./...
|
- go install ./...
|
||||||
|
- diff -u <(echo -n) <(gofmt -d .)
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
|
|
|
@ -62,5 +62,4 @@ func TestBindFlagValue(t *testing.T) {
|
||||||
flag.Changed = true //hack for pflag usage
|
flag.Changed = true //hack for pflag usage
|
||||||
|
|
||||||
assert.Equal(t, "testing_mutate", Get("testvalue"))
|
assert.Equal(t, "testing_mutate", Get("testvalue"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,14 @@ func (rc remoteConfigProvider) Watch(rp viper.RemoteProvider) (io.Reader, error)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp,err := cm.Get(rp.Path())
|
resp, err := cm.Get(rp.Path())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes.NewReader(resp), nil
|
return bytes.NewReader(resp), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *viper.RemoteResponse, chan bool) {
|
func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *viper.RemoteResponse, chan bool) {
|
||||||
cm, err := getConfigManager(rp)
|
cm, err := getConfigManager(rp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -47,13 +48,13 @@ func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *vi
|
||||||
}
|
}
|
||||||
quit := make(chan bool)
|
quit := make(chan bool)
|
||||||
quitwc := make(chan bool)
|
quitwc := make(chan bool)
|
||||||
viperResponsCh := make(chan *viper.RemoteResponse)
|
viperResponsCh := make(chan *viper.RemoteResponse)
|
||||||
cryptoResponseCh := cm.Watch(rp.Path(), quit)
|
cryptoResponseCh := cm.Watch(rp.Path(), quit)
|
||||||
// need this function to convert the Channel response form crypt.Response to viper.Response
|
// need this function to convert the Channel response form crypt.Response to viper.Response
|
||||||
go func(cr <-chan *crypt.Response,vr chan<- *viper.RemoteResponse, quitwc <-chan bool, quit chan<- bool) {
|
go func(cr <-chan *crypt.Response, vr chan<- *viper.RemoteResponse, quitwc <-chan bool, quit chan<- bool) {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <- quitwc:
|
case <-quitwc:
|
||||||
quit <- true
|
quit <- true
|
||||||
return
|
return
|
||||||
case resp := <-cr:
|
case resp := <-cr:
|
||||||
|
@ -65,15 +66,12 @@ func (rc remoteConfigProvider) WatchChannel(rp viper.RemoteProvider) (<-chan *vi
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}(cryptoResponseCh,viperResponsCh,quitwc,quit)
|
}(cryptoResponseCh, viperResponsCh, quitwc, quit)
|
||||||
|
|
||||||
return viperResponsCh,quitwc
|
|
||||||
|
|
||||||
|
return viperResponsCh, quitwc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func getConfigManager(rp viper.RemoteProvider) (crypt.ConfigManager, error) {
|
func getConfigManager(rp viper.RemoteProvider) (crypt.ConfigManager, error) {
|
||||||
|
|
||||||
var cm crypt.ConfigManager
|
var cm crypt.ConfigManager
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -99,7 +97,6 @@ func getConfigManager(rp viper.RemoteProvider) (crypt.ConfigManager, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return cm, nil
|
return cm, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCopyAndInsensitiviseMap(t *testing.T) {
|
func TestCopyAndInsensitiviseMap(t *testing.T) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
given = map[string]interface{}{
|
given = map[string]interface{}{
|
||||||
"Foo": 32,
|
"Foo": 32,
|
||||||
|
|
1
viper.go
1
viper.go
|
@ -1546,7 +1546,6 @@ func (v *Viper) searchInPath(in string) (filename string) {
|
||||||
// Search all configPaths for any config file.
|
// Search all configPaths for any config file.
|
||||||
// Returns the first path that exists (and is a config file).
|
// Returns the first path that exists (and is a config file).
|
||||||
func (v *Viper) findConfigFile() (string, error) {
|
func (v *Viper) findConfigFile() (string, error) {
|
||||||
|
|
||||||
jww.INFO.Println("Searching for config in ", v.configPaths)
|
jww.INFO.Println("Searching for config in ", v.configPaths)
|
||||||
|
|
||||||
for _, cp := range v.configPaths {
|
for _, cp := range v.configPaths {
|
||||||
|
|
Loading…
Reference in a new issue