| 1480 | func SetDefault(key string, value any) { v.SetDefault(key, value) } |
| 1481 | |
| 1482 | func (v *Viper) SetDefault(key string, value any) { |
| 1483 | // If alias passed in, then set the proper default |
| 1484 | key = v.realKey(strings.ToLower(key)) |
| 1485 | value = toCaseInsensitiveValue(value) |
| 1486 | |
| 1487 | path := strings.Split(key, v.keyDelim) |
| 1488 | lastKey := strings.ToLower(path[len(path)-1]) |
| 1489 | deepestMap := deepSearch(v.defaults, path[0:len(path)-1]) |
| 1490 | |
| 1491 | // set innermost value |
| 1492 | deepestMap[lastKey] = value |
| 1493 | } |
| 1494 | |
| 1495 | // Set sets the value for the key in the override register. |
| 1496 | // Set is case-insensitive for a key. |