mirror of
https://github.com/spf13/viper
synced 2025-05-07 12:47:18 +00:00
Fix error formatting based on best practices from Code Review Comments
Signed-off-by: CodeLingo Bot <bot@codelingo.io>
This commit is contained in:
parent
d104d259b3
commit
020e5b5ba3
1 changed files with 3 additions and 3 deletions
6
viper.go
6
viper.go
|
@ -930,7 +930,7 @@ func BindEnv(input ...string) error { return v.BindEnv(input...) }
|
||||||
func (v *Viper) BindEnv(input ...string) error {
|
func (v *Viper) BindEnv(input ...string) error {
|
||||||
var key, envkey string
|
var key, envkey string
|
||||||
if len(input) == 0 {
|
if len(input) == 0 {
|
||||||
return fmt.Errorf("BindEnv missing key to bind to")
|
return fmt.Errorf("bindEnv missing key to bind to")
|
||||||
}
|
}
|
||||||
|
|
||||||
key = strings.ToLower(input[0])
|
key = strings.ToLower(input[0])
|
||||||
|
@ -1315,7 +1315,7 @@ func (v *Viper) writeConfig(filename string, force bool) error {
|
||||||
jww.INFO.Println("Attempting to write configuration to file.")
|
jww.INFO.Println("Attempting to write configuration to file.")
|
||||||
ext := filepath.Ext(filename)
|
ext := filepath.Ext(filename)
|
||||||
if len(ext) <= 1 {
|
if len(ext) <= 1 {
|
||||||
return fmt.Errorf("Filename: %s requires valid extension.", filename)
|
return fmt.Errorf("filename: %s requires valid extension", filename)
|
||||||
}
|
}
|
||||||
configType := ext[1:]
|
configType := ext[1:]
|
||||||
if !stringInSlice(configType, SupportedExts) {
|
if !stringInSlice(configType, SupportedExts) {
|
||||||
|
@ -1331,7 +1331,7 @@ func (v *Viper) writeConfig(filename string, force bool) error {
|
||||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||||
flags = os.O_WRONLY
|
flags = os.O_WRONLY
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("File: %s exists. Use WriteConfig to overwrite.", filename)
|
return fmt.Errorf("file: %s exists. Use WriteConfig to overwrite", filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f, err := v.fs.OpenFile(filename, flags, os.FileMode(0644))
|
f, err := v.fs.OpenFile(filename, flags, os.FileMode(0644))
|
||||||
|
|
Loading…
Add table
Reference in a new issue