helpers: Silence some Golint warnings

This commit is contained in:
Bjørn Erik Pedersen 2016-03-22 23:53:19 +01:00
parent 283b866386
commit b0e21f967b

View file

@ -35,7 +35,7 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
// Filepath separator defined by os.Separator. // FilePathSeparator as defined by os.Separator.
const FilePathSeparator = string(filepath.Separator) const FilePathSeparator = string(filepath.Separator)
// FindAvailablePort returns an available and valid TCP port. // FindAvailablePort returns an available and valid TCP port.
@ -92,7 +92,7 @@ func FirstUpper(s string) string {
// UniqueStrings returns a new slice with any duplicates removed. // UniqueStrings returns a new slice with any duplicates removed.
func UniqueStrings(s []string) []string { func UniqueStrings(s []string) []string {
unique := make([]string, 0) var unique []string
set := map[string]interface{}{} set := map[string]interface{}{}
for _, val := range s { for _, val := range s {
if _, ok := set[val]; !ok { if _, ok := set[val]; !ok {
@ -230,13 +230,13 @@ func NewDistinctErrorLogger() *DistinctLogger {
return &DistinctLogger{m: make(map[string]bool), logger: jww.ERROR} return &DistinctLogger{m: make(map[string]bool), logger: jww.ERROR}
} }
// NewDistinctErrorLogger creates a new DistinctLogger that can be used // NewDistinctFeedbackLogger creates a new DistinctLogger that can be used
// to give feedback to the user while not spamming with duplicates. // to give feedback to the user while not spamming with duplicates.
func NewDistinctFeedbackLogger() *DistinctLogger { func NewDistinctFeedbackLogger() *DistinctLogger {
return &DistinctLogger{m: make(map[string]bool), logger: &jww.FEEDBACK} return &DistinctLogger{m: make(map[string]bool), logger: &jww.FEEDBACK}
} }
// Avoid spamming the logs with errors // DistinctErrorLog cann be used to avoid spamming the logs with errors.
var DistinctErrorLog = NewDistinctErrorLogger() var DistinctErrorLog = NewDistinctErrorLogger()
// Deprecated logs ERROR logs about a deprecation, but only once for a given set of arguments' values. // Deprecated logs ERROR logs about a deprecation, but only once for a given set of arguments' values.
@ -430,9 +430,8 @@ func DoArithmetic(a, b interface{}, op rune) (interface{}, error) {
return af + bf, nil return af + bf, nil
} else if au != 0 || bu != 0 { } else if au != 0 || bu != 0 {
return au + bu, nil return au + bu, nil
} else {
return 0, nil
} }
return 0, nil
case '-': case '-':
if ai != 0 || bi != 0 { if ai != 0 || bi != 0 {
return ai - bi, nil return ai - bi, nil
@ -440,9 +439,8 @@ func DoArithmetic(a, b interface{}, op rune) (interface{}, error) {
return af - bf, nil return af - bf, nil
} else if au != 0 || bu != 0 { } else if au != 0 || bu != 0 {
return au - bu, nil return au - bu, nil
} else {
return 0, nil
} }
return 0, nil
case '*': case '*':
if ai != 0 || bi != 0 { if ai != 0 || bi != 0 {
return ai * bi, nil return ai * bi, nil
@ -450,9 +448,8 @@ func DoArithmetic(a, b interface{}, op rune) (interface{}, error) {
return af * bf, nil return af * bf, nil
} else if au != 0 || bu != 0 { } else if au != 0 || bu != 0 {
return au * bu, nil return au * bu, nil
} else {
return 0, nil
} }
return 0, nil
case '/': case '/':
if bi != 0 { if bi != 0 {
return ai / bi, nil return ai / bi, nil
@ -460,9 +457,8 @@ func DoArithmetic(a, b interface{}, op rune) (interface{}, error) {
return af / bf, nil return af / bf, nil
} else if bu != 0 { } else if bu != 0 {
return au / bu, nil return au / bu, nil
} else {
return nil, errors.New("Can't divide the value by 0")
} }
return nil, errors.New("Can't divide the value by 0")
default: default:
return nil, errors.New("There is no such an operation") return nil, errors.New("There is no such an operation")
} }