Skip to content

Commit

Permalink
skip linting additional test files
Browse files Browse the repository at this point in the history
Signed-off-by: Pranay Valson <[email protected]>
  • Loading branch information
noslav committed Jan 2, 2025
1 parent 4956f6b commit 6fddc7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
run:
timeout: 5m
modules-download-mode: readonly
skip-files:
- "internal/config/utils_test.go"
skip-dirs:
- internal/metrics
- bin/
Expand Down
9 changes: 8 additions & 1 deletion internal/config/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,32 @@ func LookupEnvOrString(key string, defaultVal string) string {
return defaultVal
}

// LookupEnvOrInt looks up a flag env that is an integer and returns its value.
// If the environment variable is not set, it returns the default value.
func LookupEnvOrInt(key string, defaultVal int) int {
if val, ok := os.LookupEnv(key); ok {
v, err := strconv.Atoi(val)
if err != nil {
panic(fmt.Sprintf("unable to lookupEnvOrInt[%s]: %v", key, err))
}

return v
}

return defaultVal
}

// LookupEnvOrInt64 looks up a flag env that is an integer
// LookupEnvOrInt64 looks up a flag env that is an integer and returns its value as int64.
// If the environment variable is not set, it returns the default value.
func LookupEnvOrInt64(key string, defaultVal int64) int64 {
if val, ok := os.LookupEnv(key); ok {
v, err := strconv.ParseInt(val, 10, 64)
if err != nil {
panic(fmt.Sprintf("unable to lookupEnvOrInt64[%s]: %v", key, err))
}

return v
}

return defaultVal
}

0 comments on commit 6fddc7b

Please sign in to comment.