mirror of
https://github.com/kopia/kopia.git
synced 2026-01-27 15:58:03 -05:00
* fixed new gocritic violations * fixed new 'contextcheck' violations * fixed 'gosec' warnings * suppressed ireturn and varnamelen linters * fixed tenv violations, enabled building robustness tests on arm64 * fixed remaining linux failures * makefile: fixed 'lint-all' target when running on arm64 * linter: increase deadline * disable nilnil linter - to be enabled in separate PR
26 lines
465 B
Go
26 lines
465 B
Go
//go:build darwin || (linux && amd64)
|
|
// +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
|
|
}
|