mostly copied from pflag's implementation of this operation here https://github.com/spf13/pflag/blob/d5e0c0615acee7028e1e2740a11102313be88de1/string_to_int.go#L68 alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap.
(val string)
| 1363 | // mostly copied from pflag's implementation of this operation here https://github.com/spf13/pflag/blob/d5e0c0615acee7028e1e2740a11102313be88de1/string_to_int.go#L68 |
| 1364 | // alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap. |
| 1365 | func stringToIntConv(val string) any { |
| 1366 | val = strings.Trim(val, "[]") |
| 1367 | // An empty string would cause an empty map |
| 1368 | if val == "" { |
| 1369 | return map[string]any{} |
| 1370 | } |
| 1371 | ss := strings.Split(val, ",") |
| 1372 | out := make(map[string]any, len(ss)) |
| 1373 | for _, pair := range ss { |
| 1374 | k, vv, found := strings.Cut(pair, "=") |
| 1375 | if !found { |
| 1376 | return nil |
| 1377 | } |
| 1378 | var err error |
| 1379 | out[k], err = strconv.Atoi(vv) |
| 1380 | if err != nil { |
| 1381 | return nil |
| 1382 | } |
| 1383 | } |
| 1384 | return out |
| 1385 | } |
| 1386 | |
| 1387 | // IsSet checks to see if the key has been set in any of the data locations. |
| 1388 | // IsSet is case-insensitive for a key. |