diff --git a/internal/configuration/reader.go b/internal/configuration/reader.go index 552a67fe..d6ac80f8 100644 --- a/internal/configuration/reader.go +++ b/internal/configuration/reader.go @@ -41,7 +41,7 @@ func readCSVPorts(env params.Env, key string) (ports []uint16, err error) { s, err := env.Get(key) if err != nil { return nil, err - } else if len(s) == 0 { + } else if s == "" { return nil, nil } @@ -95,7 +95,7 @@ var ( func readIP(env params.Env, key string) (ip net.IP, err error) { s, err := env.Get(key) - if len(s) == 0 { + if s == "" { return nil, nil } else if err != nil { return nil, err @@ -115,7 +115,7 @@ func readPortOrZero(env params.Env, key string) (port uint16, err error) { return 0, err } - if len(s) == 0 || s == "0" { + if s == "" || s == "0" { return 0, nil } diff --git a/internal/configuration/secrets.go b/internal/configuration/secrets.go index 978a92ca..67a45632 100644 --- a/internal/configuration/secrets.go +++ b/internal/configuration/secrets.go @@ -65,7 +65,7 @@ func (r *reader) getFromEnvOrSecretFile(envKey string, compulsory bool, retroKey value = string(b) value = cleanSuffix(value) - if compulsory && len(value) == 0 { + if compulsory && value == "" { return "", ErrSecretFileIsEmpty } diff --git a/internal/httpproxy/auth.go b/internal/httpproxy/auth.go index 04d2e5d9..f2ebdc23 100644 --- a/internal/httpproxy/auth.go +++ b/internal/httpproxy/auth.go @@ -7,11 +7,11 @@ import ( ) func (h *handler) isAuthorized(responseWriter http.ResponseWriter, request *http.Request) (authorized bool) { - if len(h.username) == 0 || (request.Method != "CONNECT" && !request.URL.IsAbs()) { + if h.username == "" || (request.Method != "CONNECT" && !request.URL.IsAbs()) { return true } basicAuth := request.Header.Get("Proxy-Authorization") - if len(basicAuth) == 0 { + if basicAuth == "" { h.logger.Info("Proxy-Authorization header not found from " + request.RemoteAddr) responseWriter.Header().Set("Proxy-Authenticate", `Basic realm="Access to Gluetun over HTTP"`) responseWriter.WriteHeader(http.StatusProxyAuthRequired) diff --git a/internal/openvpn/logs.go b/internal/openvpn/logs.go index bf0fa3eb..7957dbb8 100644 --- a/internal/openvpn/logs.go +++ b/internal/openvpn/logs.go @@ -24,7 +24,7 @@ func (l *looper) collectLines(stdout, stderr <-chan string, done chan<- struct{} return } line, level := processLogLine(line) - if len(line) == 0 { + if line == "" { continue // filtered out } if errLine { diff --git a/internal/routing/reader.go b/internal/routing/reader.go index 33119bd3..c9ea2736 100644 --- a/internal/routing/reader.go +++ b/internal/routing/reader.go @@ -76,7 +76,7 @@ func (r *routing) DefaultIP() (ip net.IP, err error) { defaultLinkName = link.Attrs().Name } } - if len(defaultLinkName) == 0 { + if defaultLinkName == "" { return nil, fmt.Errorf("%w: in %d route(s)", ErrLinkDefaultNotFound, len(routes)) } diff --git a/internal/updater/openvpn/extract.go b/internal/updater/openvpn/extract.go index 116f97d9..d5a225d4 100644 --- a/internal/updater/openvpn/extract.go +++ b/internal/updater/openvpn/extract.go @@ -76,7 +76,7 @@ func extractRemoteHosts(content []byte, rejectIP, rejectDomain bool) (hosts []st continue } fields := strings.Fields(line) - if len(fields) == 1 || len(fields[1]) == 0 { + if len(fields) == 1 || fields[1] == "" { continue } host := fields[1] diff --git a/internal/updater/updater.go b/internal/updater/updater.go index 1649fc89..2c1575a6 100644 --- a/internal/updater/updater.go +++ b/internal/updater/updater.go @@ -35,7 +35,7 @@ type updater struct { func New(settings configuration.Updater, httpClient *http.Client, currentServers models.AllServers, logger logging.Logger) Updater { - if len(settings.DNSAddress) == 0 { + if settings.DNSAddress == "" { settings.DNSAddress = "1.1.1.1" } unzipper := unzip.New(httpClient) diff --git a/maintenance.md b/maintenance.md index 346cbfab..10da816b 100644 --- a/maintenance.md +++ b/maintenance.md @@ -14,7 +14,6 @@ ## Code -- Change empty string comparison from `len(s) == 0` to `s == ""` - Use `github.com/qdm12/ddns-updater/pkg/publicip` - Change firewall debug logs to use `logger.Debug` instead of `fmt.Println`