Files
kopia/tests/robustness/options.go
Nathan Baulch 657fda216a chore(ci): upgrade to golangci-lint 2.6.1 (#4973)
- upgrade to golangci-lint 2.6.1
- updates for gosec
- updates for govet
- updates for perfsprint
- updates modernize

Leaves out modernize:omitempty due to conflicts with tests
2025-11-11 21:27:10 -08:00

25 lines
436 B
Go

//go:build darwin || (linux && amd64)
package robustness
import "strconv"
// GetOptAsIntOrDefault extracts an integer value from a configuration map
// if present, or else returns a default.
func GetOptAsIntOrDefault(key string, opts map[string]string, def int) int {
if opts == nil {
return def
}
if opts[key] == "" {
return def
}
retInt, err := strconv.Atoi(opts[key])
if err != nil {
return def
}
return retInt
}