From 2ef5e86aaf104aac861880a0912cad825b5416ba Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Tue, 24 Aug 2021 17:19:21 +0300 Subject: [PATCH] [#770] node/config: Add uint32 casting Signed-off-by: Pavel Karpy --- cmd/neofs-node/config/cast.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmd/neofs-node/config/cast.go b/cmd/neofs-node/config/cast.go index 2f6c5d520..b8e4b4938 100644 --- a/cmd/neofs-node/config/cast.go +++ b/cmd/neofs-node/config/cast.go @@ -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. //