Fix golint

This commit is contained in:
Mark Sagi-Kazar 2019-12-06 12:46:23 +01:00 committed by Márk Sági-Kazár
parent 29bb3ee94f
commit 8b7fbcaa4b
3 changed files with 4 additions and 6 deletions

View File

@ -12,8 +12,6 @@ linters:
# TODO: fix me # TODO: fix me
- wsl - wsl
- golint
- stylecheck
- gochecknoinits - gochecknoinits
- misspell - misspell
- gosimple - gosimple

View File

@ -970,7 +970,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("missing key to bind to")
} }
key = strings.ToLower(input[0]) key = strings.ToLower(input[0])
@ -1347,7 +1347,7 @@ func (v *Viper) WriteConfig() error {
func SafeWriteConfig() error { return v.SafeWriteConfig() } func SafeWriteConfig() error { return v.SafeWriteConfig() }
func (v *Viper) SafeWriteConfig() error { func (v *Viper) SafeWriteConfig() error {
if len(v.configPaths) < 1 { if len(v.configPaths) < 1 {
return errors.New("Missing configuration for 'configPath'") return errors.New("missing configuration for 'configPath'")
} }
return v.SafeWriteConfigAs(filepath.Join(v.configPaths[0], v.configName+"."+v.configType)) return v.SafeWriteConfigAs(filepath.Join(v.configPaths[0], v.configName+"."+v.configType))
} }
@ -1372,7 +1372,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) {

View File

@ -1447,7 +1447,7 @@ func TestSafeWriteConfigWithMissingConfigPath(t *testing.T) {
v.SetFs(fs) v.SetFs(fs)
v.SetConfigName("c") v.SetConfigName("c")
v.SetConfigType("yaml") v.SetConfigType("yaml")
require.EqualError(t, v.SafeWriteConfig(), "Missing configuration for 'configPath'") require.EqualError(t, v.SafeWriteConfig(), "missing configuration for 'configPath'")
} }
func TestSafeWriteConfigWithExistingFile(t *testing.T) { func TestSafeWriteConfigWithExistingFile(t *testing.T) {