MSP-8172 Add vendor

This commit is contained in:
Синельник Тимур Романович committed 2026-07-29 12:52:27 +03:00
1 parent 5175d87e08
commit eb066cb055
2619 files changed
+757077 -2

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
package config
import (
"time"
)
// Optional provides access to configuration values with defaults.
// All methods return the provided default value if the key is not found or cannot be parsed.
// Unlike Mandatory, these methods never return errors.
type Optional struct {
m Mandatory
}
// Int retrieves an integer configuration value or returns the default.
// Returns defValue if the key is not found or the value cannot be parsed as an integer.
func (o Optional) Int(key string, defValue int) int {
value, err := o.m.Int(key)
if err != nil {
return defValue
}
return value
}
// String retrieves a string configuration value or returns the default.
// Returns defValue if the key is not found.
func (o Optional) String(key string, defValue string) string {
value, err := o.m.String(key)
if err != nil {
return defValue
}
return value
}
// Bool retrieves a boolean configuration value or returns the default.
// Returns defValue if the key is not found or the value cannot be parsed as a boolean.
func (o Optional) Bool(key string, defValue bool) bool {
value, err := o.m.Bool(key)
if err != nil {
return defValue
}
return value
}
// Duration retrieves a time.Duration configuration value or returns the default.
// Returns defValue if the key is not found or the value cannot be parsed as a duration.
func (o Optional) Duration(key string, defValue time.Duration) time.Duration {
value, err := o.m.Duration(key)
if err != nil {
return defValue
}
return value
}