[#770] node/config: Add uint32 casting

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-08-24 17:19:21 +03:00 committed by Pavel Karpy
parent d77b2d1b76
commit 2ef5e86aaf

View file

@ -88,6 +88,25 @@ func BoolSafe(c *Config, name string) bool {
return cast.ToBool(c.Value(name))
}
// Uint32 reads configuration value
// from c by name and casts it to uint32.
//
// Panics if value can not be casted.
func Uint32(c *Config, name string) uint32 {
x, err := cast.ToUint32E(c.Value(name))
panicOnErr(err)
return x
}
// Uint32Safe reads configuration value
// from c by name and casts it to uint32.
//
// Returns 0 if value can not be casted.
func Uint32Safe(c *Config, name string) uint32 {
return cast.ToUint32(c.Value(name))
}
// Uint reads configuration value
// from c by name and casts it to uint64.
//