mirror of
https://github.com/kopia/kopia.git
synced 2026-03-29 03:21:32 -04:00
- 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
25 lines
436 B
Go
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
|
|
}
|