Fix error formatting based on best practices from Code Review Comments

Signed-off-by: CodeLingo Bot <bot@codelingo.io>
This commit is contained in:
CodeLingo Bot 2019-02-05 05:51:37 +00:00
parent d104d259b3
commit 020e5b5ba3

View file

@ -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))