Fix golint issues in pkg/util/env

This commit is contained in:
Stefan Bueringer 2019-09-27 17:25:19 +02:00
parent 898042007c
commit fa36b19e79
No known key found for this signature in database
GPG Key ID: D405233560D47A0A
2 changed files with 6 additions and 1 deletions

View File

@ -230,7 +230,6 @@ pkg/serviceaccount
pkg/ssh
pkg/util/config
pkg/util/ebtables
pkg/util/env
pkg/util/goroutinemap/exponentialbackoff
pkg/util/iptables
pkg/util/iptables/testing

6
pkg/util/env/env.go vendored
View File

@ -21,6 +21,8 @@ import (
"strconv"
)
// GetEnvAsStringOrFallback returns the env variable for the given key
// and falls back to the given defaultValue if not set
func GetEnvAsStringOrFallback(key, defaultValue string) string {
if v := os.Getenv(key); v != "" {
return v
@ -28,6 +30,8 @@ func GetEnvAsStringOrFallback(key, defaultValue string) string {
return defaultValue
}
// GetEnvAsIntOrFallback returns the env variable (parsed as integer) for
// the given key and falls back to the given defaultValue if not set
func GetEnvAsIntOrFallback(key string, defaultValue int) (int, error) {
if v := os.Getenv(key); v != "" {
value, err := strconv.Atoi(v)
@ -39,6 +43,8 @@ func GetEnvAsIntOrFallback(key string, defaultValue int) (int, error) {
return defaultValue, nil
}
// GetEnvAsFloat64OrFallback returns the env variable (parsed as float64) for
// the given key and falls back to the given defaultValue if not set
func GetEnvAsFloat64OrFallback(key string, defaultValue float64) (float64, error) {
if v := os.Getenv(key); v != "" {
value, err := strconv.ParseFloat(v, 64)