forked from TrueCloudLab/frostfs-node
[#770] node/config: Add uint32 casting
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
d77b2d1b76
commit
2ef5e86aaf
1 changed files with 19 additions and 0 deletions
|
@ -88,6 +88,25 @@ func BoolSafe(c *Config, name string) bool {
|
||||||
return cast.ToBool(c.Value(name))
|
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
|
// Uint reads configuration value
|
||||||
// from c by name and casts it to uint64.
|
// from c by name and casts it to uint64.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue