From 6257ff123f288f155990491e078f55c2e9c72247 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Wed, 28 Nov 2018 13:37:42 +0300 Subject: [PATCH] Fix gometalinter warnings --- app.go | 6 +++--- control.go | 7 +------ helpers.go | 7 +------ i18n.go | 5 +---- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/app.go b/app.go index 3544da90..b8fa54c4 100644 --- a/app.go +++ b/app.go @@ -202,7 +202,7 @@ func getInput() (string, error) { func promptAndGet(prompt string) (string, error) { for { - fmt.Printf(prompt) + fmt.Print(prompt) input, err := getInput() if err != nil { log.Printf("Failed to get input, aborting: %s", err) @@ -217,9 +217,9 @@ func promptAndGet(prompt string) (string, error) { func promptAndGetPassword(prompt string) (string, error) { for { - fmt.Printf(prompt) + fmt.Print(prompt) password, err := terminal.ReadPassword(int(os.Stdin.Fd())) - fmt.Printf("\n") + fmt.Print("\n") if err != nil { log.Printf("Failed to get input, aborting: %s", err) return "", err diff --git a/control.go b/control.go index e5dc5b00..3e4dcabf 100644 --- a/control.go +++ b/control.go @@ -669,12 +669,7 @@ func (filter *filter) save() error { filterFilePath := filter.Path() log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath) - err := safeWriteFile(filterFilePath, filter.Contents) - if err != nil { - return err - } - - return nil + return safeWriteFile(filterFilePath, filter.Contents) } // loads filter contents from the file in dataDir diff --git a/helpers.go b/helpers.go index 66955033..cf3156da 100644 --- a/helpers.go +++ b/helpers.go @@ -31,12 +31,7 @@ func safeWriteFile(path string, data []byte) error { if err != nil { return err } - err = os.Rename(tmpPath, path) - if err != nil { - return err - } - - return nil + return os.Rename(tmpPath, path) } // ---------------------------------- diff --git a/i18n.go b/i18n.go index 25aaf153..4a52813a 100644 --- a/i18n.go +++ b/i18n.go @@ -24,10 +24,7 @@ var allowedLanguages = map[string]bool{ func isLanguageAllowed(language string) bool { l := strings.ToLower(language) - if allowedLanguages[l] { - return true - } - return false + return allowedLanguages[l] } func handleI18nCurrentLanguage(w http.ResponseWriter, r *http.Request) {