config: add name to each config imp

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-01-29 16:18:17 +03:00
parent bcd7f6a551
commit 87e1480077
2 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,7 @@ var (
// Config is an interface abstraction for dynamic configuration
type Config interface {
Name() string
// Init the config
Init(opts ...Option) error
// Options in the config

View File

@ -251,6 +251,10 @@ func (c *defaultConfig) String() string {
return "default"
}
func (c *defaultConfig) Name() string {
return c.opts.Name
}
func NewConfig(opts ...Option) Config {
options := NewOptions(opts...)
if len(options.StructTag) == 0 {