mostly copied from pflag's implementation of this operation here https://github.com/spf13/pflag/blob/master/string_to_string.go#L79 alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap.
(val string)
| 1339 | // mostly copied from pflag's implementation of this operation here https://github.com/spf13/pflag/blob/master/string_to_string.go#L79 |
| 1340 | // alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap. |
| 1341 | func stringToStringConv(val string) any { |
| 1342 | val = strings.Trim(val, "[]") |
| 1343 | // An empty string would cause an empty map |
| 1344 | if val == "" { |
| 1345 | return map[string]any{} |
| 1346 | } |
| 1347 | r := csv.NewReader(strings.NewReader(val)) |
| 1348 | ss, err := r.Read() |
| 1349 | if err != nil { |
| 1350 | return nil |
| 1351 | } |
| 1352 | out := make(map[string]any, len(ss)) |
| 1353 | for _, pair := range ss { |
| 1354 | k, vv, found := strings.Cut(pair, "=") |
| 1355 | if !found { |
| 1356 | return nil |
| 1357 | } |
| 1358 | out[k] = vv |
| 1359 | } |
| 1360 | return out |
| 1361 | } |
| 1362 | |
| 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. |